AI Gateway
Call OpenAI and Anthropic models through one OpenAI-compatible endpoint with a Cloady API token, at each provider's list price, with budgets and rate limits per key.
Cloady AI is an OpenAI-compatible gateway. Point any OpenAI SDK, or anything else that speaks the OpenAI Chat Completions API, at Cloady, authenticate with a Cloady API token, and call models from OpenAI and Anthropic by name. Each key gets its own models, budget and rate limit, and requests are logged with their tokens, cost and latency.
- Base URL:
https://cloady.com/api/ai/v1 - Endpoints:
GET /models,POST /chat/completionsandPOST /embeddings. OpenAI's other APIs, such as Responses, Assistants, images, audio and files, aren't served. - Authentication:
Authorization: Bearer cldy_…, a Cloady API token with the AI gateway permission. - Providers: OpenAI and Anthropic. Google, xAI, Mistral, DeepSeek and Meta are listed as coming soon.
- Price: up to 60 free requests an hour per account, each capped at $0.25 of list price; past that, each provider's list price per token, with no markup.
Get a key
The gateway takes an ordinary Cloady API token that has the AI gateway permission. There are two ways to make one:
- A key for one workspace. In the AI tool, open API keys and click Create key. The key can only call the gateway, is pinned to the workspace, and starts with the workspace's defaults for new keys: a $20 monthly budget, 60 requests a minute and every enabled model.
- A token for your account. In Account settings → API tokens, click + New token and tick AI gateway under Permissions, then pick its models, a monthly budget and a rate limit. Under Workspaces, keep All workspaces or pin it to one. Full account doesn't include AI gateway access, so tick both if one token should do both.
Copy the cldy_… secret when it's shown: Cloady keeps only a hash of it. A key made
in the AI tool also appears in Account settings → API tokens, and editing it in
either place changes the same token. A token that has only the AI gateway
permission is refused by the rest of the Cloady API.
Each permission in a token's row under Account settings → API tokens turns on or off with a click. While AI gateway is off, the token can't call the gateway and the AI tool doesn't list it; its models, budget and rate limit are kept for when you turn it back on.
Make a request
curl https://cloady.com/api/ai/v1/chat/completions \
-H "Authorization: Bearer $CLOADY_AI_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "anthropic/claude-sonnet-5-5", "messages": [{"role": "user", "content": "Hello"}]}'The answer is an OpenAI chat completion, whichever provider served it. Its model
field and the X-Cloady-Model response header name the model that answered, which
tells you which one served a call to an alias.
Watch usage and spend
The AI tool's Overview shows the last 24 hours of requests, errors, tokens and median latency, spend by model, and this month's spend against the workspace budget. Logs lists the latest requests one by one. What you pay shows in Account settings → Billing, under Usage balance.
Use an OpenAI SDK
Set the base URL and the key when you create the client, then call models by their Cloady ID or by an alias.
Node.js
import OpenAI from "openai";
const ai = new OpenAI({
baseURL: "https://cloady.com/api/ai/v1",
apiKey: process.env.CLOADY_AI_KEY,
});
const stream = await ai.chat.completions.create({
model: "chat",
messages: [{ role: "user", content: "Write a haiku about DNS." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}Python
import os
from openai import OpenAI
ai = OpenAI(
base_url="https://cloady.com/api/ai/v1",
api_key=os.environ["CLOADY_AI_KEY"],
)
reply = ai.chat.completions.create(
model="openai/gpt-6.1-sol",
messages=[{"role": "user", "content": "Hello"}],
)
print(reply.choices[0].message.content)
vectors = ai.embeddings.create(
model="openai/text-embedding-3-small",
input=["first text", "second text"],
)
print(len(vectors.data))In an app on Cloady
Store the key as a secret variable in the app's Settings → Environment, such as
CLOADY_AI_KEY, and read it as above. The official OpenAI SDKs also read
OPENAI_BASE_URL and OPENAI_API_KEY from the environment, so code that already
uses one can switch by setting those two variables, as long as it names Cloady's
model IDs.
Authentication and workspaces
Send the token as a bearer token. Each request runs in one workspace, or in none:
| Token | X-Cloady-Workspace header | The request uses |
|---|---|---|
| Pinned to a workspace | none, or that workspace's slug | that workspace's models, settings and budget |
| Pinned to a workspace | another workspace's slug | nothing: it's refused with 403 workspace_mismatch |
| Unpinned | a workspace's slug | that workspace's models, settings and budget |
| Unpinned | none | your account, with the gateway's default settings |
When a request names a workspace, the key's owner must be a member of it
(403 not_a_member). A request without a
workspace runs on the gateway's default settings: every model but the premium ones,
as far as the key's own model list allows, and the default model, aliases and
limits. It counts toward no workspace budget. It counts toward the key's budget and
shows under Account settings → Billing, but not in any workspace's usage or logs.
The OpenAI SDKs send the header on every request when you set it on the client:
const ai = new OpenAI({
baseURL: "https://cloady.com/api/ai/v1",
apiKey: process.env.CLOADY_AI_KEY,
defaultHeaders: { "X-Cloady-Workspace": "acme" },
});ai = OpenAI(
base_url="https://cloady.com/api/ai/v1",
api_key=os.environ["CLOADY_AI_KEY"],
default_headers={"X-Cloady-Workspace": "acme"},
)Models
Model IDs are provider/model. GET /v1/models lists the models and aliases the key
can call right now. The whole catalog, with each model's list prices per million
tokens, is public: GET https://cloady.com/api/ai/models and
cloady.com/ai.
| Model ID | Context | Can do |
|---|---|---|
anthropic/claude-opus-5-5 | 1M | tools, vision, reasoning |
anthropic/claude-sonnet-5-5 | 1M | tools, vision, reasoning |
anthropic/claude-haiku-5-5 | 1M | tools, vision, reasoning |
anthropic/claude-fable-5-2 | 1M | tools, vision, reasoning |
openai/gpt-6.2-sol | 1.05M | tools, vision, reasoning |
openai/gpt-6.1-sol | 1.05M | tools, vision, reasoning |
openai/gpt-6.2-astra | 1.05M | tools, vision, reasoning |
openai/gpt-6.1-terra | 1.05M | vision, reasoning |
openai/gpt-6-luna | 1.05M | tools, vision, reasoning |
openai/text-embedding-3-small | 8K | embeddings |
openai/text-embedding-3-large | 8K | embeddings |
The catalog changes over time; the two endpoints above always answer with the current list.
In a workspace, every model starts on except the premium ones, whose output costs
$40 or more per million tokens (Claude Fable 5.2 and GPT-6.2 Astra today), and a
model added to the catalog later starts off. Admins switch models on and off in the
AI tool's Models, which also sets the default model a request gets when it
leaves model out: Claude Sonnet 5.5 unless changed.
Aliases
Call an alias instead of a model and the gateway picks the model, retries it and falls back to the next one for you. Every workspace starts with three:
| Alias | Models | Order |
|---|---|---|
chat | Claude Sonnet 5.5, GPT-6.2 Sol | In order |
fast | Claude Haiku 5.5, GPT-6 Luna | Fastest first, by recent answers |
cheap | GPT-6 Luna, Claude Haiku 5.5 | Cheapest first, by list price |
Admins edit them in the AI tool's Routing & cache: up to 20 aliases of up to eight models each. Reliability there decides what happens when an attempt fails:
- Retry and fall back on names the failures that are retried and that move an alias on to its next model: Provider errors and Rate limits by default. Any other failure is answered at once.
- Retries: how many more times a model is tried after one of those failures, from none to 3; 2 by default, waiting 300 ms and longer between tries, up to 3 seconds.
- Timeout: how long one attempt may take, 60 seconds by default.
Timeouts are off in that list by default: a provider may still bill an attempt it didn't finish in time, so every attempt that times out is charged for its prompt. A request without a workspace uses these defaults.
Chat completions
POST /v1/chat/completions takes the OpenAI request format:
| Field | Notes |
|---|---|
model | A model ID or an alias. Left out, the workspace's default model. |
messages | Roles system, developer, user, assistant and tool; text and image parts; tool calls and tool results. |
stream, stream_options.include_usage | See Streaming. |
max_completion_tokens, max_tokens | Clamped to the workspace's Max tokens per reply, 16,384 by default; that limit also applies when you send neither. A free request's limit can be lowered further; see Free usage and pricing. |
tools, tool_choice, parallel_tool_calls | Function tools. |
response_format | text, json_object or json_schema. |
reasoning_effort | Passed to the model, or mapped for Anthropic models. |
stop, user, safety_identifier | |
temperature, top_p, n, seed, presence_penalty, frequency_penalty, logit_bias, logprobs, top_logprobs, verbosity, prompt_cache_key | Sent to OpenAI models only. |
Fields outside this list aren't sent to the provider. A request body can be up to 32 MB and hold up to 2,000 messages.
Anthropic models
The gateway turns the request into Anthropic's Messages API and the answer back into an OpenAI chat completion. What that changes:
- System and developer messages become the system prompt.
- An image must be an
httpsURL or a base64 data URL of a JPEG, PNG, GIF or WebP image. A PDF goes in afilepart as a base64 data URL. response_formatwithjson_schemabecomes Anthropic's structured output;json_objectbecomes an instruction to answer with one JSON object.reasoning_effortbecomes Anthropic's effort setting;noneandminimalcount aslow.tool_choice: "required"or a named function becomes an instruction to call the tool, not a guarantee, because Anthropic refuses forced tool use while a model is thinking.nmust be 1, and sampling parameters such astemperatureare left out.stopbecomes Anthropic's stop sequences, anduser, orsafety_identifier, becomes its user ID.- In the answer,
finish_reasonislengthwhen the output limit was reached,tool_callswhen the model called a tool, andcontent_filterwhen it declined; an answer that isn't streamed then carries the model's explanation inmessage.refusal.
Streaming
Stream anything that may take a while. cloady.com sits behind Cloudflare, which closes a response that has sent nothing for 100 seconds: a request that isn't streamed and takes longer is cut off, while the gateway still finishes it and charges it. A request that isn't streamed must also finish within the workspace's timeout per attempt, 60 seconds by default; a streamed one only has to start within it.
Streams use OpenAI's format: data: chunks, then data: [DONE]. While a model is
silent for 15 seconds or more, the gateway sends : ping comment lines, which SDKs
skip. With stream_options: {"include_usage": true}, the last chunk carries the
token counts. An error after the stream has started arrives as a data: event with
an error object, and the stream ends there. Closing a stream early stops the
answer; the request is charged for its prompt and the output sent until then.
curl -N https://cloady.com/api/ai/v1/chat/completions \
-H "Authorization: Bearer $CLOADY_AI_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "fast", "stream": true, "stream_options": {"include_usage": true}, "messages": [{"role": "user", "content": "Count to five."}]}'Embeddings
POST /v1/embeddings serves openai/text-embedding-3-small, which it uses when
model is left out, and openai/text-embedding-3-large. input is a string or an
array; dimensions and encoding_format pass through.
curl https://cloady.com/api/ai/v1/embeddings \
-H "Authorization: Bearer $CLOADY_AI_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "openai/text-embedding-3-small", "input": ["first text", "second text"]}'Free usage and pricing
A request is free when both of these hold:
- Your account has used fewer than 60 free requests in the past hour. It's the same allowance Ask AI uses, and the AI tool's chat draws on it too.
- Its worst case costs $0.25 or less at list price. The gateway works that out
before it sends the request: the prompt counted generously, one token per byte of
text or file and 6,000 per image, plus the whole output limit, at the prices of
the dearest model the request may go to. When the prompt fits but the whole output
limit doesn't, the gateway lowers the output limit to what fits, as long as that
leaves at least 256 tokens, so a free answer can stop early with
finish_reasonset tolength.
Every other request is paid, at its provider's list price for the tokens it used, with no markup: input and output tokens at the model's prices per million, cached input at the provider's cached price, Anthropic cache writes at 1.25 times the input price, and a provider's higher long-prompt prices for a prompt above the model's threshold. Each model's prices are in the catalog.
Charges come out of the prepaid usage balance of the account that owns the key, so a key you share with someone is billed to you. In Account settings → Billing → Usage balance:
- Add funds charges your account card at once, with no fee. The dashboard offers $10 to $250; the API takes $5 to $1,000.
- Monthly limit caps what your usage may be charged in a UTC month. Leave it empty for no limit.
A paid request holds its worst case on the balance while it runs; when it finishes,
it's charged what it used and the rest is released. It gets 402 balance_empty
when the balance can't hold its worst case, and 402 usage_limit when its worst
case would take this month's charges past the monthly limit. A lower max_tokens
lowers the worst case. Free requests keep working either way.
Budgets and limits
Keys
Each key has its own limits, set when it's created and changed in its Settings in the AI tool or in Account settings → API tokens:
| Limit | What it does |
|---|---|
| Monthly budget | Caps what the key is charged in a UTC month, in US dollars, across every workspace. Free requests don't count. A paid request whose worst case doesn't fit in what's left gets 402 budget_reached. Once the key's charges reach the budget, it pauses with the reason Budget reached until the next UTC month starts, or until its budget is raised above this month's spend or removed. |
| Rate limit | Requests a minute, from 1 to 1,200; 60 unless set. Past it, the key answers 429 rate_limit_exceeded with a Retry-After header in seconds. |
| Models | All enabled follows the workspace's model list; Only these limits the key to the models picked. |
| Expiry | Set when the key is created: never, or in 30 days, 90 days or 1 year. |
Pause stops a key at once (402 key_paused) until it's resumed. Rotate
secret gives it a new secret: the old one stops working immediately, and the key
keeps its limits and history. Revoke ends a key that can only call the gateway
for good; on a token that has other permissions too, the button reads Remove AI
access and removes only that. Share with only labels a key with the person
it's for; Cloady never sends it to them.
A key's owner can do all of this. A workspace admin can also pause another member's key, change its limits and models, or revoke it, as long as the key can only call the gateway and is pinned to the workspace. Only the owner renames a key, changes who it's shared with, rotates it or sees its secret.
An account can have at most 8 requests running at once, across all its keys and the
AI tool's chat. One more gets 429 too_many_requests with Retry-After: 1.
Workspace
Admins set these in Workspace settings → AI and in the AI tool's Limits & guardrails:
| Setting | Default | What it does |
|---|---|---|
| Monthly budget | $100 | What the gateway may charge across every key in the workspace each UTC month. |
| When it's reached | Notify members | Notify members emails and keeps answering. Pause every key answers 402 workspace_budget_reached to every request once the budget is reached, and before that to a paid request whose worst case doesn't fit in what's left, until the next month or a higher budget. Workspace settings → AI calls them Notify me and Pause requests. |
| Email alerts | 50%, 80% and 100% | Sent to the members who keep incident emails on in Account settings → Notifications. |
| Defaults for new keys | $20, 60 requests a minute, all enabled models | What Create key starts with. |
| Redact personal data | Off | Masks email addresses, phone numbers and card numbers in prompts before they leave Cloady. |
| Log prompts & responses | Off | Keeps the last user message and the reply, up to 4,000 characters each, in the request log for 7, 30 or 90 days. Only developers and above can read them. Without it, the log keeps tokens, cost and latency only. |
| Max tokens per reply | 16,384 | Larger requests are clamped to it. |
Roles
| Role | Can |
|---|---|
| Viewer | See usage, models, keys and the request log, without prompt text |
| Developer | Chat in the AI tool, read prompt text in the log, create keys and change their own |
| Admin, owner | Change models, budgets, guardrails and routing; pause, limit or revoke members' keys that can only call the gateway and are pinned to the workspace |
Errors
Errors come back in OpenAI's format, so SDKs raise them as usual:
{
"error": {
"message": "This key allows 60 requests a minute",
"type": "rate_limit_error",
"code": "rate_limit_exceeded",
"param": null
}
}| Status | code | What it means |
|---|---|---|
| 400 | invalid_request, invalid_json, model_required, missing_messages, unsupported_model, unsupported_parameter, unsupported_content, unsupported_image, unsupported_file | The body is malformed, names an embeddings model for chat or the reverse, or holds something the model can't take. A provider's own 4xx passes through with its message. |
| 401 | invalid_api_key | The token is missing, unknown, revoked or expired. |
| 402 | balance_empty, usage_limit | A paid request's worst case is more than the usage balance holds, or would take this month's charges past the monthly limit. |
| 402 | budget_reached, workspace_budget_reached | The key's budget, or the workspace's when it's set to pause, is reached or has too little left for a paid request's worst case. |
| 402 | key_paused | The key is paused. |
| 403 | no_ai_access | The token doesn't have the AI gateway permission. |
| 403 | account_blocked | The account that owns the token is blocked. |
| 403 | not_a_member, workspace_not_found, workspace_mismatch | The workspace the request names can't be used: see Authentication and workspaces. |
| 403 | model_not_enabled, model_not_allowed | The model is off in the workspace, or not on the key's list. |
| 404 | model_not_found | No model or alias has that name, or its provider isn't available yet. |
| 413 | request_too_large | The request body is larger than 32 MB. |
| 429 | rate_limit_exceeded | The key's requests a minute are used up; wait the seconds in Retry-After. |
| 429 | too_many_requests | The account already has 8 requests running. |
| 500 | internal_error | The gateway failed. Try again. |
| 502 | provider_error | The provider failed, or stopped partway through an answer. |
| 503 | provider_rate_limited, provider_unavailable | The provider is rate-limiting Cloady, or the model can't be reached right now. |
| 504 | timeout | The model didn't answer within the timeout. |
Before it answers with one of the last three, the gateway retries the failures its reliability settings name: provider errors and provider rate limits by default.
The AI tool
Open AI from the sidebar, or Workspace settings → AI → Open AI. It starts on a list of everything that can answer in the workspace: Chat, Gateway, one tile per key, and the models your own apps serve.
- Chat sends a conversation to any enabled model. It's free or charged to you by the same rules as a gateway request. In the tab of a key you can manage, Chat as this key applies that key's models, budget and rate limit. Chats are kept in your browser, not on Cloady.
- Gateway has Overview, Models, Providers, API keys, Limits & guardrails, Routing & cache and Logs. Logs shows the latest 90 requests; narrow it by status, or search by model, alias or key name. A request the gateway refuses before it calls a provider, over a budget or a rate limit for instance, isn't logged.
- A key's tab has its own Usage, Logs and Settings.
- Self-hosted models: apps in the workspace that run a model server such as Ollama or vLLM show up with the models they serve, and chatting with them is free. Workspace settings → AI links to deploying one.
Using your own provider keys, the content filter and the response cache are shown as coming soon and aren't available yet.
API
The gateway's settings, keys, usage and logs are part of the
Cloady API: getWorkspaceAi, updateWorkspaceAi,
listAiKeys, createAiKey, updateAiKey, rotateAiKey, revokeAiKey,
getAiUsage, listAiLogs, readAiLogText, chatAi and listAiServers, plus the
public listAiCatalog. listAiLogs returns entries without their text;
readAiLogText reads one entry's prompt and response and needs the developer role.
The usage balance is getBalance, updateBalance and topUpBalance. Creating,
changing, rotating and revoking keys there needs a token with the Full account
permission. These operations live under https://cloady.com/api and answer with
Cloady's own error format, not the gateway's.