Anthropic SDK

odnoga exposes /v1/messages and translates to/from OpenAI shape internally — point the Anthropic SDK at the same base URL.

Setup

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

const anthropic = new Anthropic({
  apiKey: process.env.AIROUTER_API_KEY!,         // virtual key, not your real Anthropic key
  baseURL: process.env.AIROUTER_BASE_URL!,       // no /v1 suffix — SDK adds it
  defaultHeaders: { 'x-airouter-end-user': 'anonymous' },
});

await anthropic.messages.create(
  {
    model: 'claude-3-5-sonnet-latest',
    max_tokens: 256,
    messages: [{ role: 'user', content: 'hi' }],
  },
  { headers: { 'x-airouter-end-user': userId } },
);

Notes

  • Your real Anthropic key lives in Vault keys. The SDK only sees the odnoga virtual key.
  • Streaming works (stream: true).
  • odnoga's response headers (x-airouter-*) are still attached — read them via .withResponse() (TS SDK) or the raw-response helper.