Quickstart
Use OpenAI Chat Completions, OpenAI Responses or Anthropic Messages for models that list those endpoints. Keep your SDK and prompts; change the base URL and key. Embeddings, decisions, images, audio, video and other capabilities have their own contracts.
- Base URL —
https://api.cloakray.com/v1 - Auth —
Authorization: Bearer ckr_..., orx-api-keyif your SDK sends that
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 CLOAKRAY_API_KEY="ckr_..."
The full secret is shown once, when the key is created. Store it then.
Chat Completions
The OpenAI-compatible endpoint, at /v1/chat/completions. Your Cloakray key goes where your provider key used to; everything else in the call stays the same.
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.cloakray.com/v1",
apiKey: process.env.CLOAKRAY_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);
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.cloakray.com/v1",
api_key=os.environ["CLOAKRAY_API_KEY"],
)
resp = client.chat.completions.create(
model="gpt-5.5",
messages=[{"role": "user", "content": "ship it"}],
)
print(resp.choices[0].message.content)
curl https://api.cloakray.com/v1/chat/completions \
-H "Authorization: Bearer $CLOAKRAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.5",
"messages": [{"role": "user", "content": "ship it"}]
}'
Messages
The Anthropic-compatible endpoint, at /v1/messages. Choose a model whose catalogue entry lists this endpoint. The Anthropic SDK's x-api-key header works like the bearer token.
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "https://api.cloakray.com",
apiKey: process.env.CLOAKRAY_API_KEY,
});
const msg = await client.messages.create({
model: "claude-opus-4-8",
max_tokens: 1024,
messages: [{ role: "user", content: "ship it" }],
});
Responses
The OpenAI-compatible endpoint at /v1/responses, used by Codex and newer OpenAI SDK methods. Choose a model whose catalogue entry lists Responses; do not assume every model supports every text interface.
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.cloakray.com/v1",
apiKey: process.env.CLOAKRAY_API_KEY,
});
const response = await client.responses.create({
model: "gpt-5.5",
input: "ship it",
});
console.log(response.output_text);
curl https://api.cloakray.com/v1/responses \
-H "Authorization: Bearer $CLOAKRAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.5",
"input": "ship it"
}'
Set store: false for a non-stored request. The reference defaults to 30-day response storage; stored Responses and previous_response_id must remain project-scoped. GET /v1/responses/{response_id} and POST /v1/responses/compact have explicit contracts and availability constraints. Cancel and delete routes are not implied.
List the models
GET /v1/models returns the catalogue in the shape OpenAI clients expect, so a tool that populates its model picker from the API finds one.
curl https://api.cloakray.com/v1/models \
-H "Authorization: Bearer $CLOAKRAY_API_KEY"
{
"object": "list",
"data": [
{
"id": "claude-opus-4-8",
"object": "model",
"created": 1700000000,
"owned_by": "anthropic",
"name": "Claude Opus 4.8",
"context_length": 1000000,
"max_output_tokens": 128000,
"input_modalities": ["text", "image"],
"output_modalities": ["text"],
"capabilities": { "vision": true, "tools": true, "reasoning": true, "streaming": true, "json_mode": false },
"endpoints": ["/v1/chat/completions", "/v1/messages", "/v1/responses"],
"pricing": { "input": 5, "output": 25, "cached_input": 0.5 }
}
]
}
Beyond the OpenAI fields, each entry carries what a client needs to use the model well: its context size and output limit, what it accepts and produces, and the paths it answers on. pricing is the list price in USD per million tokens, before any discount on your account. Entries also include a description.
Each entry's endpoints tells you where that model may be called. Discovery does not bypass workspace entitlements, and a record is not proof that every modality or transport is enabled. Listing models is free. Use your project key for account-specific discovery; invalid supplied credentials fail. See compatibility differences for filters and privacy.
Streaming
Set stream: true and tokens arrive as they are generated. Usage is still counted, so streamed requests show up in your logs like any other.
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
Most agents need a base URL and a key and nothing else. Claude Code takes two environment variables; the others want a provider block or a settings form. Each one has its own page under coding agents, and SDKs, frameworks and apps are under integrations.
Errors
Errors come back in the shape your SDK already expects, with a message that says what to do about it.
| Status | What it means |
|---|---|
401 | The key is missing, malformed, or no longer active. |
402 | Your balance is too low to cover the request. Top up, or turn on auto top-up. |
403 | The key's workspace can't use that model or endpoint — for example, a Token Plan key calling a model the plan does not cover. Use a key from a workspace that can. |
404 | That model isn't on this endpoint. The response lists the ones that are. |
429 | Too many requests in a short time. Wait for the time in the Retry-After header, then retry. |
503 | We couldn't confirm your balance, so nothing was sent or charged. Retry. |
Every status, and how to retry, is on the errors page.
Next
- Models — choosing a model, IDs, and what
GET /v1/modelsreturns - Tool calling, structured outputs and reasoning — the features most apps reach for next
- Integrations — the AI SDK, LangChain, LlamaIndex, MCP and more
- Check what it costs — per-token pricing and what you are charged for