Documentation

Build LLM-powered agents
with production-ready TypeScript

DSPy for TypeScript. Working with LLMs is complex—they don't always do what you want. DSPy makes it easier to build amazing things with LLMs. Just define your inputs and outputs (signature) and an efficient prompt is auto-generated and used. Connect together various signatures to build complex systems and workflows using LLMs.

15+ LLM Providers
End-to-end Streaming
Auto Prompt Tuning

AxAgentConfig

Defined in: https://github.com/ax-llm/ax/blob/05ff5bd88d050f7ba85a3fcc6eb0ed2975ad7d51/src/ax/prompts/agent.ts#L635

Configuration options for creating an agent using the agent() factory function.

Extends

Type Parameters

Type Parameter
IN extends AxGenIn
OUT extends AxGenOut

Properties

PropertyTypeDescriptionOverridesInherited from
abortSignal?AbortSignalAbortSignal for cancelling in-flight requests.-AxAgentOptions.abortSignal
agents?AxAgentic<IN, OUT>[]---
ai?AxAIService<unknown, unknown, string>-AxAgentOptions.ai-
asserts?AxAssertion<any>[]--AxAgentOptions.asserts
cachingFunction?(key: string, value?: AxGenOut) => | undefined | AxGenOut | Promise<undefined | AxGenOut>--AxAgentOptions.cachingFunction
contextCache?AxContextCacheOptionsContext caching options for large prompt prefixes. When enabled, large prompt prefixes can be cached for cost savings and lower latency on subsequent requests. Currently supported by: Google Gemini/Vertex AI-AxAgentOptions.contextCache
corsProxy?stringCORS proxy URL for browser environments. When running in a browser, API calls may be blocked by CORS. Specify a proxy URL to route requests through. Example 'https://cors-anywhere.herokuapp.com/'-AxAgentOptions.corsProxy
customLabels?Record<string, string>Custom labels for OpenTelemetry metrics. These labels are merged with axGlobals.customLabels (service-level options override global settings). Example { environment: 'production', feature: 'search' }-AxAgentOptions.customLabels
debug?booleanEnable debug logging for troubleshooting. When true, logs detailed information about prompts, responses, and the generation pipeline. Useful for understanding AI behavior.-AxAgentOptions.debug
debugHideSystemPrompt?booleanHide system prompt in debug output (for cleaner logs).-AxAgentOptions.debugHideSystemPrompt
definition?string---
descriptionstring-AxAgentOptions.description-
disableMemoryCleanup?boolean--AxAgentOptions.disableMemoryCleanup
disableSmartModelRouting?boolean--AxAgentOptions.disableSmartModelRouting
examplesInSystem?booleanRender examples/demos in the system prompt instead of as message pairs. - false (default) - Examples rendered as alternating user/assistant messages - true - Examples embedded in system prompt (legacy behavior) Message pair rendering generally produces better results.-AxAgentOptions.examplesInSystem
excludeContentFromTrace?booleanExclude message content from OpenTelemetry traces (for privacy).-AxAgentOptions.excludeContentFromTrace
excludeFieldsFromPassthrough?string[]List of field names that should not be automatically passed from parent to child agents-AxAgentOptions.excludeFieldsFromPassthrough
fastFail?boolean--AxAgentOptions.fastFail
fetch?{ (input: URL | RequestInfo, init?: RequestInit): Promise<Response>; (input: string | URL | Request, init?: RequestInit): Promise<Response>; }Custom fetch implementation (useful for proxies or custom HTTP handling).-AxAgentOptions.fetch
functionCall?| "auto" | "none" | "required" | { function: { name: string; }; type: "function"; }--AxAgentOptions.functionCall
functionCallMode?"auto" | "native" | "prompt"How to handle function/tool calling. - 'auto' - Let the provider decide the best approach (default) - 'native' - Use the provider’s native function calling API. Fails if the model doesn’t support it. - 'prompt' - Simulate function calling via prompt engineering. Works with any model but may be less reliable. Default 'auto'-AxAgentOptions.functionCallMode
functionResultFormatter?(result: unknown) => string--AxAgentOptions.functionResultFormatter
functions?AxInputFunctionType---
logger?AxLoggerFunctionCustom logger function for debug output.-AxAgentOptions.logger
maxRetries?number--AxAgentOptions.maxRetries
maxSteps?number--AxAgentOptions.maxSteps
mem?AxAIMemory--AxAgentOptions.mem
meter?MeterOpenTelemetry meter for metrics collection.-AxAgentOptions.meter
model?string--AxAgentOptions.model
modelConfig?AxModelConfig--AxAgentOptions.modelConfig
namestring---
promptTemplate?typeof AxPromptTemplate--AxAgentOptions.promptTemplate
rateLimiter?AxRateLimiterFunctionCustom rate limiter function to control request throughput.-AxAgentOptions.rateLimiter
resultPicker?AxResultPickerFunction<AxGenOut>--AxAgentOptions.resultPicker
retry?Partial<RetryConfig>Retry configuration for failed requests. Controls automatic retry behavior for transient errors (rate limits, timeouts, server errors).-AxAgentOptions.retry
sampleCount?number--AxAgentOptions.sampleCount
sessionId?stringSession identifier for conversation tracking and memory isolation.-AxAgentOptions.sessionId
showThoughts?booleanInclude the model’s thinking/reasoning in the output. When true and thinkingTokenBudget is set, the model’s internal reasoning is included in the response. Useful for debugging and understanding AI behavior. Default false-AxAgentOptions.showThoughts
stepIndex?numberInternal: Current step index for multi-step operations.-AxAgentOptions.stepIndex
stopFunction?string | string[]--AxAgentOptions.stopFunction
stream?booleanEnable streaming responses. When true, the AI returns responses as a stream of chunks, enabling real-time display of generated text.-AxAgentOptions.stream
streamingAsserts?AxStreamingAssertion[]--AxAgentOptions.streamingAsserts
strictMode?boolean--AxAgentOptions.strictMode
thinkingTokenBudget?"high" | "low" | "none" | "medium" | "minimal" | "highest"Token budget for extended thinking (chain-of-thought reasoning). Extended thinking allows models to “think through” complex problems before responding. Higher budgets allow deeper reasoning but cost more. Approximate token allocations: - 'none' - Disabled (default) - 'minimal' - ~1,000 tokens (~750 words of thinking) - 'low' - ~4,000 tokens - 'medium' - ~10,000 tokens - 'high' - ~20,000 tokens - 'highest' - ~32,000+ tokens (provider maximum) Provider support: - Anthropic Claude: Full support with claude-sonnet-4 and above - OpenAI: Supported with o1/o3 models (uses reasoning_effort) - Google: Supported with Gemini 2.0 Flash Thinking - DeepSeek: Supported with DeepSeek-R1 Example // Enable medium thinking for complex reasoning await gen.forward(ai, values, { thinkingTokenBudget: 'medium' });-AxAgentOptions.thinkingTokenBudget
thoughtFieldName?string--AxAgentOptions.thoughtFieldName
timeout?numberRequest timeout in milliseconds. Default 300000 (5 minutes)-AxAgentOptions.timeout
traceContext?ContextOpenTelemetry trace context for distributed tracing.-AxAgentOptions.traceContext
traceLabel?string--AxAgentOptions.traceLabel
tracer?TracerOpenTelemetry tracer for distributed tracing.-AxAgentOptions.tracer
useExpensiveModel?"yes"Hint to use a more capable (and expensive) model for complex tasks. Some providers offer tiered models. Setting this to ‘yes’ requests the higher-capability tier when available.-AxAgentOptions.useExpensiveModel
verbose?booleanEnable low-level HTTP request/response logging. More verbose than debug. Shows raw HTTP traffic including headers. Useful for debugging API issues.-AxAgentOptions.verbose