ai() API
LLM provider, model, media, routing, and embedding APIs.
Most Used
ai
Create a provider client from a provider name and options.
| Field | Value |
|---|---|
| Kind | function |
| Ax concept | ai |
| API section | AxAI |
| Form | ai(provider='openai', **options) |
| Returns | AI client/service |
Important Options
api keymodelapi URLheaderstransport
Examples
client = ai("openai", api_key=os.environ["OPENAI_API_KEY"])OpenAICompatibleClient
OpenAI-compatible chat, stream, embedding, audio, and realtime provider boundary.
| Field | Value |
|---|---|
| Kind | type |
| Ax concept | OpenAICompatibleClient |
| API section | AxAI |
| Form | OpenAICompatibleClient(options=None) |
| Returns | provider client |
Important Options
api keymodelbase URLtransport
OpenAIResponsesClient
OpenAI Responses provider mapping using the same Core-owned request and response contract.
| Field | Value |
|---|---|
| Kind | type |
| Ax concept | OpenAIResponsesClient |
| API section | AxAI |
| Form | OpenAIResponsesClient(options=None) |
| Returns | provider client |
Important Options
api keymodelaudiorealtime
GoogleGeminiClient
Gemini provider mapping for chat, streaming, media, tools, embeddings, and usage normalization.
| Field | Value |
|---|---|
| Kind | type |
| Ax concept | GoogleGeminiClient |
| API section | AxAI |
| Form | GoogleGeminiClient(options=None) |
| Returns | provider client |
Important Options
api keymodelembed model
AnthropicClient
Anthropic provider mapping for messages, thinking, cache control, streaming, and usage normalization.
| Field | Value |
|---|---|
| Kind | type |
| Ax concept | AnthropicClient |
| API section | AxAI |
| Form | AnthropicClient(options=None) |
| Returns | provider client |
Important Options
api keymodelthinkingcache control
AxBalancer
Retry and route requests across multiple provider services while preserving Ax request shape.
| Field | Value |
|---|---|
| Kind | type |
| Ax concept | AxBalancer |
| API section | AxAI |
| Form | AxBalancer(services, options=None) |
| Returns | AI service |
Important Options
servicesretry policycapability requirements
MultiServiceRouter
Choose a service by capability or model routing policy.
| Field | Value |
|---|---|
| Kind | type |
| Ax concept | MultiServiceRouter |
| API section | AxAI |
| Form | MultiServiceRouter(services) |
| Returns | AI service |
Important Options
servicesrouting
ProviderRouter
Route provider requests to registered provider clients.
| Field | Value |
|---|---|
| Kind | type |
| Ax concept | ProviderRouter |
| API section | AxAI |
| Form | ProviderRouter(providers, routing=None, processing=None) |
| Returns | AI service |
Important Options
providersroutingprocessing
Full Reference
Open the full Python reference. This page highlights the ai symbols most relevant to everyday use.