ai() API Provider, model, routing, media, and embedding APIs. go api api/ai packages/go/axir-api.json api ai() API

ai() API

LLM provider, model, media, routing, and embedding APIs.

Most Used

axllm.NewAI

Create a provider client from a named deployment profile and options.

FieldValue
Kindfunction
Ax conceptai
API sectionAxAI
Formaxllm.NewAI(provider, options)
ReturnsAIClient

Important Options

  • api key or credential provider
  • model
  • api URL
  • headers
  • transport

Examples

Go
client := axllm.NewAI("openai", map[string]axllm.Value{"apiKey": os.Getenv("OPENAI_API_KEY")})

Full reference

axllm.OpenAICompatibleClient

OpenAI-compatible chat, stream, embedding, audio, and realtime provider boundary.

FieldValue
Kindtype
Ax conceptOpenAICompatibleClient
API sectionAxAI
Formaxllm.NewOpenAICompatibleClient(options)
Returnsprovider client

Important Options

  • api key
  • model
  • base URL
  • transport

Full reference

axllm.OpenAIResponsesClient

OpenAI Responses provider mapping using the same Core-owned request and response contract.

FieldValue
Kindtype
Ax conceptOpenAIResponsesClient
API sectionAxAI
Formaxllm.NewOpenAIResponsesClient(options)
Returnsprovider client

Important Options

  • api key
  • model
  • audio
  • realtime

Full reference

axllm.GoogleGeminiClient

Gemini provider mapping for chat, streaming, media, tools, embeddings, and usage normalization.

FieldValue
Kindtype
Ax conceptGoogleGeminiClient
API sectionAxAI
Formaxllm.NewGoogleGeminiClient(options)
Returnsprovider client

Important Options

  • api key
  • model
  • embed model

Full reference

axllm.AnthropicClient

Anthropic provider mapping for messages, thinking, cache control, streaming, and usage normalization.

FieldValue
Kindtype
Ax conceptAnthropicClient
API sectionAxAI
Formaxllm.NewAnthropicClient(options)
Returnsprovider client

Important Options

  • api key
  • model
  • thinking
  • cache control

Full reference

axllm.AxBalancer

Retry and route requests across multiple provider services, with opt-in adaptive cost, reliability, and deadline routing.

FieldValue
Kindtype
Ax conceptAxBalancer
API sectionAxAI
Formaxllm.NewAxBalancer(services, options)
ReturnsAI service

Important Options

  • services
  • retry policy
  • capability requirements
  • adaptive strategy

Full reference

axllm.MultiServiceRouter

Choose a service by capability or model routing policy.

FieldValue
Kindtype
Ax conceptMultiServiceRouter
API sectionAxAI
Formaxllm.MultiServiceRouter
ReturnsAI service

Important Options

  • services
  • routing

Full reference

axllm.ProviderRouter

Route requests by capability, preserving native media for supporting providers and degrading only when required.

FieldValue
Kindtype
Ax conceptProviderRouter
API sectionAxAI
Formaxllm.ProviderRouter
ReturnsAI service

Important Options

  • providers
  • routing
  • processing

Full reference

Advanced / internals / full reference

axllm.GetSupportedAIModels

Return the AxIR-backed provider and model catalog, including dynamic named profiles and portable capability metadata.

FieldValue
Kindfunction
Ax conceptget_supported_ai_models
API sectionAxAI
Formaxllm.GetSupportedAIModels(options)
Returnsprovider catalog entries

Important Options

  • type filter
  • thinkingLevels
  • serviceTiers
  • isDynamic

Examples

Go
catalog := axllm.GetSupportedAIModels(map[string]axllm.Value{})

Full reference

axllm.AxCredentialRequest

Request metadata passed to a renewable credential callback for every transport attempt.

FieldValue
Kindtype
Ax conceptAxCredentialRequest
API sectionAxAI
Formaxllm.AxCredentialRequest
Returnscredential request

Important Options

  • profile
  • operation
  • method
  • URL

Full reference

axllm.AxCredentialProvider

Return fresh request headers that override static profile authentication.

FieldValue
Kindinterface
Ax conceptAxCredentialProvider
API sectionAxAI
Formaxllm.AxCredentialProvider
Returnsheader map or credential error

Important Options

  • chat
  • stream
  • embeddings
  • Responses
  • audio
  • retries

Full reference

axllm.AxChatStream

Incremental, closeable provider event stream. Retry and failover stop once content is delivered.

FieldValue
Kindtype
Ax conceptAxProviderStream
API sectionAxAI
Formclient.StreamEvents(ctx, request, options)
Returnsincremental chat events

Important Options

  • next event
  • terminal error
  • consumer cancellation
  • upstream close

Examples

Go
stream, err := client.StreamEvents(ctx, request, nil)

Full reference

axllm.AxUsageContext

Application attribution merged from service defaults and per-call overrides.

FieldValue
Kindtype
Ax conceptAxUsageContext
API sectionAxAI
Formaxllm.AxUsageContext
Returnsusage context

Important Options

  • tenant
  • user
  • request
  • run
  • feature
  • attributes

Full reference

axllm.AxUsageEvent

Normalized token usage and correlation data for one completed chat or embedding operation.

FieldValue
Kindtype
Ax conceptAxUsageEvent
API sectionAxAI
Formaxllm.AxUsageEvent
Returnsusage event

Important Options

  • provider
  • model
  • tokens
  • context
  • correlation IDs
  • streaming

Full reference

axllm.AxUsageObserver

Best-effort process-wide callback for normalized usage events.

FieldValue
Kindinterface
Ax conceptAxUsageObserver
API sectionAxAI
Formaxllm.AxUsageObserver
Returnsusage observer

Important Options

  • fail-open delivery
  • synchronous enqueue

Full reference

axllm.SetUsageObserver

Register, replace, or clear the process-wide usage observer.

FieldValue
Kindfunction
Ax conceptset_usage_observer
API sectionAxAI
Formaxllm.SetUsageObserver(observer)
Returnsvoid

Important Options

  • observer
  • clear

Examples

Go
axllm.SetUsageObserver(func(event axllm.AxUsageEvent) { events = append(events, event) })

Full reference

axllm.AxRuntimeHooks

Non-serializable rate limiter, tracer, and meter overrides for one service or program execution.

FieldValue
Kindtype
Ax conceptAxRuntimeHooks
API sectionAxAI
Formaxllm.AxRuntimeHooks
Returnsruntime hooks

Important Options

  • rate limiter
  • tracer
  • meter
  • precedence

Examples

Go
hooks := axllm.AxRuntimeHooks{RateLimiter: limiter, Tracer: tracer, Meter: meter}

Full reference

axllm.AxRateLimitInfo

Provider and model metadata supplied to a request-wrapper rate limiter.

FieldValue
Kindtype
Ax conceptAxRateLimitInfo
API sectionAxAI
Formaxllm.AxRateLimitInfo
Returnsrate-limit context

Important Options

  • operation
  • provider
  • model
  • streaming
  • previous usage

Full reference

axllm.AxRateLimiter

Request wrapper that can delay, reject, or execute a chat or embedding request.

FieldValue
Kindinterface
Ax conceptAxRateLimiter
API sectionAxAI
Formaxllm.AxRateLimiter
Returnsprovider result

Important Options

  • next
  • metadata
  • errors

Full reference

axllm.AxTracer

Dependency-neutral tracer that creates metadata-only Ax spans.

FieldValue
Kindinterface
Ax conceptAxTracer
API sectionAxAI
Formaxllm.AxTracer
Returnsspan

Important Options

  • start span
  • parent span
  • fail-open

Full reference

axllm.AxMeter

Dependency-neutral meter for Ax counters, histograms, and gauges.

FieldValue
Kindinterface
Ax conceptAxMeter
API sectionAxAI
Formaxllm.AxMeter
Returnsinstrument

Important Options

  • counter
  • histogram
  • gauge
  • fail-open

Full reference

axllm.AxGlobals

Process-wide live defaults for runtime hooks and usage observation.

FieldValue
Kindtype
Ax conceptAxGlobals
API sectionAxAI
Formaxllm.AxGlobals
Returnsglobal hooks

Important Options

  • rate limiter
  • tracer
  • meter
  • usage observer

Full reference

axllm.SetRateLimiter

Register, replace, or clear the process-wide request-wrapper rate limiter.

FieldValue
Kindfunction
Ax conceptset_rate_limiter
API sectionAxAI
Formaxllm.SetRateLimiter(limiter)
Returnsvoid

Important Options

  • limiter
  • clear

Examples

Go
axllm.SetRateLimiter(limiter)

Full reference

axllm.SetTracer

Register, replace, or clear the process-wide dependency-neutral tracer.

FieldValue
Kindfunction
Ax conceptset_tracer
API sectionAxAI
Formaxllm.SetTracer(tracer)
Returnsvoid

Important Options

  • tracer
  • clear

Examples

Go
axllm.SetTracer(tracer)

Full reference

axllm.SetMeter

Register, replace, or clear the process-wide dependency-neutral meter.

FieldValue
Kindfunction
Ax conceptset_meter
API sectionAxAI
Formaxllm.SetMeter(meter)
Returnsvoid

Important Options

  • meter
  • clear

Examples

Go
axllm.SetMeter(meter)

Full reference

axllm.AxBalancerAdaptiveStrategy

Configure adaptive provider routing without changing the ordered default.

FieldValue
Kindtype
Ax conceptAxBalancerAdaptiveStrategy
API sectionAxAI
Formaxllm.AxBalancerAdaptiveStrategy
Returnsadaptive strategy

Important Options

  • deadline
  • bad outcome cost
  • expected tokens
  • stable route keys
  • slice
  • stats store
  • routing events

Full reference

axllm.AxBalancerStatsStore

Store shared adaptive decision state with atomic observations.

FieldValue
Kindinterface
Ax conceptAxBalancerStatsStore
API sectionAxAI
Formaxllm.AxBalancerStatsStore
Returnsstats store

Important Options

  • get
  • observe

Full reference

axllm.AxInMemoryBalancerStatsStore

Thread-safe in-memory adaptive stats store.

FieldValue
Kindtype
Ax conceptAxInMemoryBalancerStatsStore
API sectionAxAI
Formaxllm.AxInMemoryBalancerStatsStore
Returnsstats store

Full reference

axllm.CreateBalancerRouteStats

Create neutral adaptive route statistics.

FieldValue
Kindfunction
Ax conceptcreate_balancer_route_stats
API sectionAxAI
Formaxllm.CreateBalancerRouteStats
Returnsroute stats

Full reference

axllm.UpdateBalancerRouteStats

Purely reduce one success or failure observation into route statistics.

FieldValue
Kindfunction
Ax conceptupdate_balancer_route_stats
API sectionAxAI
Formaxllm.UpdateBalancerRouteStats
Returnsroute stats

Important Options

  • current stats
  • observation

Full reference

axllm.SampleBalancerRouteHealth

Sample failure and deadline-miss probability for adaptive exploration.

FieldValue
Kindfunction
Ax conceptsample_balancer_route_health
API sectionAxAI
Formaxllm.SampleBalancerRouteHealth
Returnssampled health

Important Options

  • route stats
  • deadline

Full reference

Full Reference

Open the full Go reference. This page highlights the ai symbols most relevant to everyday use.

Docs