For the complete documentation index, see llms.txt. This page is also available as Markdown.
Vercel AI SDK
Using Infron with Vercel AI SDK
Infron exposes an OpenAI-compatible API that can be used with the Vercel AI SDK through @ai-sdk/openai-compatible.
This guide shows how to configure the provider, run text generation, stream responses, use tool calling, enable request debugging, and pass Anthropic-specific tool options when needed.
Install
npminstallai@ai-sdk/openai-compatiblezod
Environment
exportINFRON_API_KEY="your-infron-api-key"
Do not expose this key in browser code. Use it from a server route, API route, or backend service.
The Vercel AI SDK standardizes tool definitions into OpenAI-compatible tool schemas.
Debugging Requests
Infron supports request and response debugging fields. They are useful when validating how an OpenAI-compatible request is mapped to an upstream provider request.
Pass debug_request and debug_response through providerOptions.infron.
When enabled, Infron responses may include debug_info.request and debug_info.response in the response body. Use these fields for development and validation only. Avoid logging them in production if prompts or payloads may contain sensitive data.
Anthropic-Specific Tool Options
Some Anthropic features use fields that are not part of the standard OpenAI tool schema, such as:
defer_loading
eager_input_streaming
tool-level cache_control
The Vercel AI SDK does not preserve arbitrary per-tool Anthropic fields by default because it normalizes tools into the OpenAI-compatible format.
To send these fields through Infron, use transformRequestBody on the OpenAI-compatible provider and inject the Anthropic-native fields into the final request body.
Use the provider with providerOptions.infron.anthropic_tool_options:
Infron routes requests across available providers based on model availability, reliability, latency, and provider capability.
When a request is naturally routed to a provider that does not support a given Anthropic-specific option, that option may not appear in the final upstream request body. Use debug_request / debug_response during integration testing to confirm the actual upstream request.
import { generateText } from 'ai';
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
const infron = createOpenAICompatible({
name: 'infron',
baseURL: 'https://llm.onerouter.pro/v1',
apiKey: process.env.INFRON_API_KEY,
});
const result = await generateText({
model: infron('anthropic/claude-sonnet-4.6'),
prompt: 'Reply with one short synthetic status sentence.',
});
console.log(result.text);
import { streamText } from 'ai';
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
const infron = createOpenAICompatible({
name: 'infron',
baseURL: 'https://llm.onerouter.pro/v1',
apiKey: process.env.INFRON_API_KEY,
});
const result = streamText({
model: infron('anthropic/claude-sonnet-4.6'),
prompt: 'Write three short bullets about a synthetic test workflow.',
});
for await (const chunk of result.textStream) {
process.stdout.write(chunk);
}