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

ai() API

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

Most Used

Ax.ai

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

FieldValue
Kindfunction
Ax conceptai
API sectionAxAI
FormAx.ai(provider, options)
ReturnsAI client/service

Important Options

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

Examples

Java
AxAIService client = Ax.ai("openai", Map.of("apiKey", System.getenv("OPENAI_API_KEY")));

Full reference

OpenAICompatibleClient

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

FieldValue
Kindtype
Ax conceptOpenAICompatibleClient
API sectionAxAI
Formnew OpenAICompatibleClient(options)
Returnsprovider client

Important Options

  • api key
  • model
  • base URL
  • transport

Full reference

OpenAIResponsesClient

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

FieldValue
Kindtype
Ax conceptOpenAIResponsesClient
API sectionAxAI
Formnew OpenAIResponsesClient(options)
Returnsprovider client

Important Options

  • api key
  • model
  • audio
  • realtime

Full reference

GoogleGeminiClient

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

FieldValue
Kindtype
Ax conceptGoogleGeminiClient
API sectionAxAI
Formnew GoogleGeminiClient(options)
Returnsprovider client

Important Options

  • api key
  • model
  • embed model

Full reference

AnthropicClient

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

FieldValue
Kindtype
Ax conceptAnthropicClient
API sectionAxAI
Formnew AnthropicClient(options)
Returnsprovider client

Important Options

  • api key
  • model
  • thinking
  • cache control

Full reference

AxBalancer

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

FieldValue
Kindtype
Ax conceptAxBalancer
API sectionAxAI
Formnew AxBalancer(services, options)
ReturnsAI service

Important Options

  • services
  • retry policy
  • capability requirements
  • adaptive strategy

Full reference

MultiServiceRouter

Choose a service by capability or model routing policy.

FieldValue
Kindtype
Ax conceptMultiServiceRouter
API sectionAxAI
Formnew AxMultiServiceRouter(services)
ReturnsAI service

Important Options

  • services
  • routing

Full reference

ProviderRouter

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

FieldValue
Kindtype
Ax conceptProviderRouter
API sectionAxAI
Formnew AxProviderRouter(providers, routing, processing)
ReturnsAI service

Important Options

  • providers
  • routing
  • processing

Full reference

Advanced / internals / full reference

Ax.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
FormAx.getSupportedAIModels(type)
Returnsprovider catalog entries

Important Options

  • type filter
  • thinkingLevels
  • serviceTiers
  • isDynamic

Examples

Java
List<Object> catalog = Ax.getSupportedAIModels();

Full reference

OpenAICompatibleClient.CredentialRequest

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

FieldValue
Kindtype
Ax conceptAxCredentialRequest
API sectionAxAI
FormOpenAICompatibleClient.CredentialRequest
Returnscredential request

Important Options

  • profile
  • operation
  • method
  • URL

Full reference

OpenAICompatibleClient.CredentialProvider

Return fresh request headers that override static profile authentication.

FieldValue
Kindinterface
Ax conceptAxCredentialProvider
API sectionAxAI
FormOpenAICompatibleClient.CredentialProvider
Returnsheader map or credential error

Important Options

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

Full reference

AxChatStream

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

FieldValue
Kindtype
Ax conceptAxProviderStream
API sectionAxAI
Formclient.openStream(request)
Returnsincremental chat events

Important Options

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

Examples

Java
try (AxChatStream stream = client.openStream(request)) { for (var event : stream) handle(event); }

Full reference

Map<String, Object>

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

FieldValue
Kindtype
Ax conceptAxUsageContext
API sectionAxAI
FormMap<String, Object>
Returnsusage context

Important Options

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

Full reference

AxUsageEvent

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

FieldValue
Kindtype
Ax conceptAxUsageEvent
API sectionAxAI
FormAxUsageEvent
Returnsusage event

Important Options

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

Full reference

AxUsageObserver

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

FieldValue
Kindinterface
Ax conceptAxUsageObserver
API sectionAxAI
FormAxUsageObserver
Returnsusage observer

Important Options

  • fail-open delivery
  • synchronous enqueue

Full reference

AxGlobals.setUsageObserver

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

FieldValue
Kindfunction
Ax conceptset_usage_observer
API sectionAxAI
FormAxGlobals.setUsageObserver(observer)
Returnsvoid

Important Options

  • observer
  • clear

Examples

Java
AxGlobals.setUsageObserver(events::add);

Full reference

AxRuntimeHooks

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

FieldValue
Kindtype
Ax conceptAxRuntimeHooks
API sectionAxAI
Formnew AxRuntimeHooks(rateLimiter, tracer, meter)
Returnsruntime hooks

Important Options

  • rate limiter
  • tracer
  • meter
  • precedence

Examples

Java
AxRuntimeHooks hooks = new AxRuntimeHooks(limiter, tracer, meter);

Full reference

AxRateLimitInfo

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

FieldValue
Kindtype
Ax conceptAxRateLimitInfo
API sectionAxAI
FormAxRateLimitInfo
Returnsrate-limit context

Important Options

  • operation
  • provider
  • model
  • streaming
  • previous usage

Full reference

AxRateLimiter

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

FieldValue
Kindinterface
Ax conceptAxRateLimiter
API sectionAxAI
FormAxRateLimiter
Returnsprovider result

Important Options

  • next
  • metadata
  • errors

Full reference

AxTracer

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

FieldValue
Kindinterface
Ax conceptAxTracer
API sectionAxAI
FormAxTracer
Returnsspan

Important Options

  • start span
  • parent span
  • fail-open

Full reference

AxMeter

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

FieldValue
Kindinterface
Ax conceptAxMeter
API sectionAxAI
FormAxMeter
Returnsinstrument

Important Options

  • counter
  • histogram
  • gauge
  • fail-open

Full reference

AxGlobals

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

FieldValue
Kindtype
Ax conceptAxGlobals
API sectionAxAI
FormAxGlobals
Returnsglobal hooks

Important Options

  • rate limiter
  • tracer
  • meter
  • usage observer

Full reference

AxGlobals.setRateLimiter

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

FieldValue
Kindfunction
Ax conceptset_rate_limiter
API sectionAxAI
FormAxGlobals.setRateLimiter(limiter)
Returnsvoid

Important Options

  • limiter
  • clear

Examples

Java
AxGlobals.setRateLimiter(limiter);

Full reference

AxGlobals.setTracer

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

FieldValue
Kindfunction
Ax conceptset_tracer
API sectionAxAI
FormAxGlobals.setTracer(tracer)
Returnsvoid

Important Options

  • tracer
  • clear

Examples

Java
AxGlobals.setTracer(tracer);

Full reference

AxGlobals.setMeter

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

FieldValue
Kindfunction
Ax conceptset_meter
API sectionAxAI
FormAxGlobals.setMeter(meter)
Returnsvoid

Important Options

  • meter
  • clear

Examples

Java
AxGlobals.setMeter(meter);

Full reference

AxBalancerAdaptiveStrategy

Configure adaptive provider routing without changing the ordered default.

FieldValue
Kindtype
Ax conceptAxBalancerAdaptiveStrategy
API sectionAxAI
FormAxBalancerAdaptiveStrategy
Returnsadaptive strategy

Important Options

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

Full reference

AxBalancerStatsStore

Store shared adaptive decision state with atomic observations.

FieldValue
Kindinterface
Ax conceptAxBalancerStatsStore
API sectionAxAI
FormAxBalancerStatsStore
Returnsstats store

Important Options

  • get
  • observe

Full reference

AxInMemoryBalancerStatsStore

Thread-safe in-memory adaptive stats store.

FieldValue
Kindtype
Ax conceptAxInMemoryBalancerStatsStore
API sectionAxAI
FormAxInMemoryBalancerStatsStore
Returnsstats store

Full reference

AxBalancerAdaptive.createRouteStats

Create neutral adaptive route statistics.

FieldValue
Kindfunction
Ax conceptcreate_balancer_route_stats
API sectionAxAI
FormAxBalancerAdaptive.createRouteStats
Returnsroute stats

Full reference

AxBalancerAdaptive.updateRouteStats

Purely reduce one success or failure observation into route statistics.

FieldValue
Kindfunction
Ax conceptupdate_balancer_route_stats
API sectionAxAI
FormAxBalancerAdaptive.updateRouteStats
Returnsroute stats

Important Options

  • current stats
  • observation

Full reference

AxBalancerAdaptive.sampleRouteHealth

Sample failure and deadline-miss probability for adaptive exploration.

FieldValue
Kindfunction
Ax conceptsample_balancer_route_health
API sectionAxAI
FormAxBalancerAdaptive.sampleRouteHealth
Returnssampled health

Important Options

  • route stats
  • deadline

Full reference

Full Reference

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

Docs