Anthropic SDK

odnoga exposes /v1/messages and translates to/from OpenAI shape internally — point the Anthropic SDK at https://api.odnoga.com (without /v1 — the SDK adds /v1/messages itself).

Setup

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

const anthropic = new Anthropic({
  apiKey: process.env.ODNOGA_API_KEY!,         // your odnoga API key, not your real Anthropic key
  baseURL: 'https://api.odnoga.com',            // no /v1 here — the Anthropic SDK appends /v1/messages itself
  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

  • If you bring your own Anthropic key, it lives under Organisation admin → Vendor keys. The SDK only ever sees your odnoga API 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.