Skip to content

Quickstart

If your code already calls OpenAI or Anthropic, you're two lines away.

Inferray speaks both the OpenAI Chat Completions and the Anthropic Messages formats. Keep your SDK, keep your prompts, change the base URL and the key.

01

Create a key

Sign up and create a key in the console. Keys are scoped to a project, so you can keep staging and production spend apart from the first request.

export INFERRAY_API_KEY="inferray_..."
02

Point your client at Inferray

The base URL is https://api.inferray.com/v1 and your Inferray key goes where your provider key used to. Everything else in your call stays the same.

Node.js — openai
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.inferray.com/v1",
  apiKey: process.env.INFERRAY_API_KEY,
});

const resp = await client.chat.completions.create({
  model: "gpt-5.5",
  messages: [{ role: "user", content: "ship it" }],
});

console.log(resp.choices[0].message.content);
Python — openai
import os

from openai import OpenAI

client = OpenAI(
    base_url="https://api.inferray.com/v1",
    api_key=os.environ["INFERRAY_API_KEY"],
)

resp = client.chat.completions.create(
    model="gpt-5.5",
    messages=[{"role": "user", "content": "ship it"}],
)

print(resp.choices[0].message.content)
curl
curl https://api.inferray.com/v1/chat/completions \
  -H "Authorization: Bearer $INFERRAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.5",
    "messages": [{"role": "user", "content": "ship it"}]
  }'
03

Or use the Anthropic SDK

Every model in the catalogue also answers on /v1/messages, including the OpenAI and Google ones. The Anthropic SDK's x-api-key header works exactly like the bearer token.

Node.js — @anthropic-ai/sdk
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  baseURL: "https://api.inferray.com",
  apiKey: process.env.INFERRAY_API_KEY,
});

const msg = await client.messages.create({
  model: "claude-fable-5",
  max_tokens: 1024,
  messages: [{ role: "user", content: "ship it" }],
});

Streaming

Set stream: true and tokens arrive as they're generated. Usage is still counted, so streamed requests show up in your logs like any other.

Node.js
const stream = await client.chat.completions.create({
  model: "gpt-5.5",
  messages: [{ role: "user", content: "ship it" }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}

Coding agents

Claude Code, Codex, and opencode all read their endpoint from the environment, so pointing them at Inferray takes two variables and no config file. Same tools, same commands, 20–70% off the bill.

shell
# Claude Code
export ANTHROPIC_BASE_URL="https://api.inferray.com"
export ANTHROPIC_AUTH_TOKEN="inferray_..."

# Codex, opencode, and other OpenAI-compatible tools
export OPENAI_BASE_URL="https://api.inferray.com/v1"
export OPENAI_API_KEY="inferray_..."

When something goes wrong

Errors come back in the shape your SDK already expects, with a message that says what to do about it.

401The key is missing, malformed, or no longer active.
402Your balance is too low to cover the request. Top up, or turn on auto top-up.
404That model isn't on this endpoint. The response lists the ones that are.
503We couldn't confirm your balance, so nothing was sent or charged. Retry.

That's the whole integration

Create a key, swap two lines, and watch the requests land in your console with tokens, latency, and cost broken out.