Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.auriko.ai/llms.txt

Use this file to discover all available pages before exploring further.

Use Auriko as your LLM provider in LangChain with a drop-in ChatOpenAI replacement. This integration is Python-only. For TypeScript, use the Vercel AI SDK integration or configure the OpenAI SDK directly with Auriko’s base URL.

Prerequisites

Installation

pip install "auriko[langchain]"

Use SDK adapter

Use the AurikoChatOpenAI adapter:
from auriko.frameworks.langchain import AurikoChatOpenAI

llm = AurikoChatOpenAI(model="gpt-5.4")
AurikoChatOpenAI extends LangChain’s ChatOpenAI with:
  • use_responses_api=False set by default (ensures routing metadata and typed error mapping)
  • Routing injection via extra_body
  • OpenAI error mapping to typed Auriko error classes
from auriko.frameworks.langchain import AurikoChatOpenAI

llm = AurikoChatOpenAI(model="gpt-5.4")

# Simple invoke
response = llm.invoke("What is 2+2?")
print(response.content)

# Streaming
for chunk in llm.stream("Count to 5"):
    print(chunk.content, end="", flush=True)

# With messages
from langchain_core.messages import HumanMessage, SystemMessage

messages = [
    SystemMessage(content="You are a helpful assistant."),
    HumanMessage(content="Explain quantum computing briefly."),
]
response = llm.invoke(messages)
print(response.content)

Configure options

AurikoChatOpenAI accepts these parameters:
ParameterTypeDefaultDescription
modelstr(required, via parent)Model ID
api_keystr | NoneAURIKO_API_KEY envAPI key
routingRoutingOptions | NoneNoneRouting configuration
base_urlstr"https://api.auriko.ai/v1"API base URL
**kwargsPassed through to ChatOpenAI (e.g., temperature, max_tokens)

Configure routing

You can pass a RoutingOptions instance to control cost, latency, and quality trade-offs:
from auriko.frameworks.langchain import AurikoChatOpenAI
from auriko.route_types import RoutingOptions

llm = AurikoChatOpenAI(
    model="gpt-5.4",
    routing=RoutingOptions(optimize="cost", max_ttft_ms=1000),
)

response = llm.invoke("Hello!")
print(response.content)
Access routing metadata through generation_info when using generate():
result = llm.generate([[HumanMessage(content="Hello!")]])
info = result.generations[0][0].generation_info
if info and "routing_metadata" in info:
    print(f"Provider: {info['routing_metadata']['provider']}")

Configure manually

If you prefer to use ChatOpenAI directly:
import os
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="gpt-5.4",
    api_key=os.environ["AURIKO_API_KEY"],
    base_url="https://api.auriko.ai/v1",
    use_responses_api=False,  # required for streaming routing metadata
)
use_responses_api=False is the default. Chat Completions streaming includes routing_metadata in the response. /v1/responses streaming does not include routing_metadata yet.

Alternative: use AurikoAsyncOpenAI (experimental)

If you can’t use auriko[langchain] (for example, your project pins a different langchain-openai version), pass AurikoAsyncOpenAI into LangChain’s async_client parameter:
from langchain_openai import ChatOpenAI
from auriko import AurikoAsyncOpenAI

client = AurikoAsyncOpenAI()
llm = ChatOpenAI(
    model="gpt-4o",
    async_client=client.chat.completions,
    api_key="placeholder",
)
Pass client.chat.completions (not the whole client) and provide any string as api_key (LangChain requires it for construction). Read client.last_routing_metadata after each call. See AurikoAsyncOpenAI for the full class reference.

Notes

  • OpenAI API errors map to typed Auriko error classes (RateLimitError, PermissionDeniedError, BadRequestError, etc.).
  • AurikoChatOpenAI sets use_responses_api=False by default.