For the complete documentation index, see llms.txt. This page is also available as Markdown.

Anthropic SDK

Use Anthropic SDK with Infron AI models

Infron supports Anthropic-compatible /v1/messages requests through the official @anthropic-ai/sdk.

Use this integration when your application already uses the Anthropic SDK or needs Anthropic-native request fields such as tools, thinking, cache_control, defer_loading, or eager_input_streaming.

Install

npm install @anthropic-ai/sdk

Environment

export INFRON_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.

Basic Text Generation

import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic({
  apiKey: process.env.INFRON_API_KEY,
  baseURL: 'https://llm.onerouter.pro',
});

const response = await client.messages.create({
  model: 'anthropic/claude-sonnet-4.6',
  max_tokens: 128,
  messages: [
    {
      role: 'user',
      content: 'Reply with one short synthetic status sentence.',
    },
  ],
});

console.log(response.content);

Streaming

Tool Calling

Debugging Requests

Infron supports debug_request and debug_response on Anthropic-compatible requests.

Use these fields during integration testing to inspect how Infron maps your SDK request to the upstream provider request and response.

When enabled, the response may include:

  • debug_info.request

  • debug_info.response

Use these fields for development and validation only. Avoid logging debug payloads in production if prompts or payloads may contain sensitive data.

Thinking

Prompt Caching

Use cache_control on content blocks or tool definitions when applicable.

Anthropic Tool Options

Anthropic supports tool-level options such as:

  • defer_loading

  • eager_input_streaming

  • cache_control

Use Anthropic-native snake_case field names.

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.

Last updated