ONEWAY is one OpenAI- and Anthropic-compatible API for every model, with spend you can see and limit. You can send your first request in about five minutes.
01
Create an account and a project.
Sign up (when sign-ups are invite-only, request early access first), then create a project for the product you're building. Keys, usage and budgets are per project.
ONEWAY runs on your own keys for now. Owners and admins add an OpenAI, Anthropic, Google Gemini or AWS Bedrock key under Provider keys; the provider bills you directly.
03
Create an API key.
On the project page. Copy it straight away, it's shown once, and keep it in a server-side environment variable such as ONEWAY_API_KEY.
04
Send a request.
Use the OpenAI SDK you already have: change the base URL and key. Model IDs are provider/model.
import OpenAI from "openai";
const ai = new OpenAI({
baseURL: "https://oneway-gateway.oneway-gateway.workers.dev/v1",
apiKey: process.env.ONEWAY_API_KEY,
});
const reply = await ai.chat.completions.create({
model: "anthropic/claude-sonnet-5-5",
messages: [{ role: "user", content: "Summarise this inbox" }],
});
console.log(reply.choices[0].message.content);
05
See it land.
The request appears under Requests in the dashboard within seconds, with its model, tokens, cost and latency. If it fails, the error's code says why: see Errors.
REFERENCE / PROVIDER KEYS
Provider keys
ONEWAY runs on your own provider keys for now. Your provider bills you directly and ONEWAY adds routing, limits and visibility on top. ONEWAY-provided models are coming soon.
01
Add a key before your first request
Owners and admins add OpenAI, Anthropic, Google Gemini or AWS Bedrock keys under Provider keys in the dashboard. A model can only be called once its provider has a key; otherwise the request fails with provider_key_missing.
02
Keys are sealed
A provider key is encrypted as soon as you save it and only the gateway can decrypt it. Nobody can read it back, including you: to change one, save a new key.
03
Other OpenAI-compatible providers
Add any provider with an OpenAI-compatible API (its base URL and key) under Other providers, give it a name, and call it as custom/<name>/<model> on /v1/chat/completions.
04
If the provider rejects the key
Requests fail with 401 provider_key_rejected and the message names the provider. Check the key in the provider's console and save it again.
Provider keys · Example
# A model from a provider you added a key for
curl https://oneway-gateway.oneway-gateway.workers.dev/v1/chat/completions \
-H "Authorization: Bearer $ONEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "anthropic/claude-haiku-5-5", "messages": [{"role": "user", "content": "Hello"}]}'
# A provider you added under Other providers as "together"
-d '{"model": "custom/together/meta-llama/Llama-3.3-70B-Instruct-Turbo", ...}'
REFERENCE / AUTHENTICATION
Authentication
Every request carries a ONEWAY API key. Keys belong to a project, so spend, limits and request history follow the product making the call.
01
Send the key as a Bearer token
Authorization: Bearer ow_live_… on every endpoint. On /v1/messages the x-api-key header that Anthropic's SDKs send works too.
02
Shown once
A key is shown when it's created and never again; ONEWAY keeps only a hash. Lost keys are replaced, not recovered.
03
test and live keys
Create test keys for development and live keys for production, so usage is reported separately and a leaked development key can be revoked without touching production.
04
Keep keys on the server
Read the key from an environment variable in server code. Never put one in browser code, a mobile app or a public repository. Revoking a key takes effect at the gateway at once.
Authentication · Example
# .env (server only, never committed)
ONEWAY_API_KEY=ow_live_...
# Any request
Authorization: Bearer $ONEWAY_API_KEY
REFERENCE / MODELS
Models
Model IDs are provider/model, so the provider is always visible in your code. GET /v1/models lists every ID with its context window.
01
Use the full ID
For example anthropic/claude-sonnet-5-5, openai/gpt-4.1 or google/gemini-3.1-pro. The Models page in the dashboard lists them with prices per million tokens.
02
Listing models
GET /v1/models takes your API key and returns the OpenAI list shape, so tools that read a model list work unchanged.
03
Capabilities differ
Tool calls, structured output, images and context windows vary by model. ONEWAY passes parameters through; the provider decides what it supports and its error message is returned to you.
POST /v1/chat/completions takes OpenAI's request shape and works with every model, whichever provider serves it.
01
Same request, any provider
Send model and messages as you would to OpenAI. ONEWAY translates the request for Claude and uses the OpenAI-compatible APIs of Gemini and Bedrock, so you always get OpenAI's response shape, usage included.
02
Streaming
Set stream: true to get server-sent events in OpenAI's chunk format. Streams are logged and counted for their full usage.
03
Tools and JSON
tools and tool_choice work with Claude as well as OpenAI-style models. Other parameters, such as response_format, are passed as sent to providers with OpenAI-compatible APIs.
Chat Completions · Example
const stream = await ai.chat.completions.create({
model: "anthropic/claude-sonnet-5-5",
messages: [{ role: "user", content: "Write a haiku about latency." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}
REFERENCE / RESPONSES AND MESSAGES
Responses and Messages
Code written for OpenAI's Responses API or Anthropic's Messages API works by changing only the base URL and key.
01
POST /v1/messages
Passed through to Claude models, streamed or not. Anthropic's SDKs send the key as x-api-key, which works, and anthropic-beta headers are passed on. Point the SDK at the gateway's root, without /v1.
02
POST /v1/responses
Passed through to OpenAI models. Other models are refused with format_unsupported and a pointer to /v1/chat/completions.
03
Same controls
Budgets, attribution headers, fallbacks, retries and the request log work the same on all three endpoints.
When a provider rate-limits or fails, the gateway can try again or move on before anything reaches your app.
01
Retry the same model
Send x-oneway-retries: 1 to 3 to retry with a short backoff before moving on. Bad requests and rejected keys are never retried.
02
Fall back to other models
Send x-oneway-fallback with up to three model IDs, in order. Each needs its provider's key. The x-oneway-model and x-oneway-attempts response headers say which model answered and how many calls it took.
03
Charged once
Only the call that answered counts towards spend, at that model's price.
Spend limits are set in the dashboard and enforced by the gateway before a request reaches the provider. The tightest one wins.
01
Project budgets
A monthly amount per project. Without a hard cap, responses carry x-oneway-budget-warning once it's passed; with one, requests stop with 402 budget_exceeded.
02
Departments and people
Teams get a monthly allocation and people a personal limit on their personal keys. Both stop requests with a 402 when reached.
03
Rate and size limits
These protect the gateway and apply to everyone. A 429 means slow down and retry with backoff.
LIMIT
VALUE
Requests per API key
600 a minute
Requests per client IP
1,200 a minute
Request body
4 MB
x-oneway-fallback
3 models
x-oneway-retries
0 to 3
Attribution header values
1–128 letters, digits and . _ : @ / -
Budgets and limits · Example
// A soft budget: the request succeeds and says so
x-oneway-budget-warning: over-monthly-budget
// A hard cap
HTTP/1.1 402
{ "error": { "type": "insufficient_quota", "code": "budget_exceeded",
"message": "This project has reached its monthly budget." } }
REFERENCE / ERRORS
Errors
Errors use OpenAI's shape (Anthropic's on /v1/messages), with ONEWAY's reason in error.code. The message says what to do.
01
Branch on the code
error.code is stable; messages may be reworded. Every response, failed or not, carries x-request-id: quote it to support or find it under Requests.
02
What to retry
429, 502 and 503 are worth retrying with backoff, or letting x-oneway-retries and x-oneway-fallback do it. 4xx errors other than 429 won't succeed on a retry.
STATUS
CODE
WHAT TO DO
400
invalid_request_error
The body isn't valid JSON, a header or field is malformed or unsupported (such as background responses), or the provider refused the request. The message says which.
400
format_unsupported
That model can't be called on this endpoint. Use /v1/chat/completions.
401
authentication_error
No API key was sent. Send it as Authorization: Bearer, or as x-api-key on /v1/messages.
401
invalid_api_key
The key is wrong or revoked. Check it was copied whole; a new key can take a minute to work after a failed try.
401
expired_api_key
The key has passed its expiry date. Create a new one on the project.
401
provider_key_rejected
Your provider turned down the key saved under Provider keys. Replace it there.
402
budget_exceeded
The project hit its hard-capped monthly budget. Raise the budget on the project.
402
department_budget_exceeded
The department's monthly allocation is used up. Ask its lead.
402
personal_limit_exceeded
Your personal monthly limit is reached. Ask your department lead.
402
organization_limit_exceeded
The organisation's monthly limit, set by ONEWAY support, is reached.
402
insufficient_balance
The ONEWAY balance is too low. Not returned while you use your own provider keys.
403
provider_key_missing
Add a key for that model's provider under Provider keys.
403
model_not_allowed
The model isn't enabled for this organisation. Contact support.
403
organization_suspended
Contact ONEWAY support.
403
custom_provider_unmetered
Your own providers' models have no price in ONEWAY, so a key under a hard limit can't call them. Use a key without one.
404
model_not_found
No such model ID, or a fallback model is wrong. GET /v1/models lists them.
404
custom_provider_not_found
No provider by that name under Provider keys, Other providers. Check custom/<name>/<model>.
404
not_found_error
Unknown path. Check the base URL ends in /v1.
413
body_too_large
Request bodies are limited to 4 MB. Send large files by URL, not inline.
429
rate_limit_error
Too many requests for the key, the organisation, your IP or the provider. Back off and retry.
500
server_error
A fault on our side. Retry, and send support the x-request-id.
502
upstream_error
The provider returned an error. Retry, or send x-oneway-fallback.
502
upstream_unreachable
The provider couldn't be reached. Retry, or send x-oneway-fallback.
503
provider_paused
The model is briefly unavailable. Retry shortly, or send x-oneway-fallback.
503
traffic_paused
ONEWAY is paused for maintenance. The message says more; retry shortly.
Errors · Example
HTTP/1.1 403
x-request-id: 3f6c2a1e-…
{
"error": {
"message": "Claude Sonnet 5.5 needs your own Anthropic key. Add it in the ONEWAY dashboard under Provider keys.",
"type": "permission_error",
"code": "provider_key_missing"
}
}
REFERENCE / REQUEST LOGS
Request logs
Every request is listed under Requests with its model, provider, tokens, cost, latency, status, retries and fallbacks.
01
Metadata always
Open any request to see what happened to it and how many attempts it took. Search by the x-request-id response header.
02
Prompts and responses only if you opt in
Owners and admins can turn on content logging and keep it for 1, 7 or 30 days. It's deleted after that, and only owners, admins and developers can read it.
03
Streams included
For streamed replies, the log keeps the assembled text, not the raw event stream.
The oneway command sets up a codebase in one step, then does everything the dashboard does from your terminal, from your AI assistant, or in plain English.
01
Set up in one command
npx @oneway-ai/cli init signs you in through the browser, creates or links this codebase's project, writes a key to .env.local, makes sure git ignores it, and checks the key works.
02
Track cost where you work
oneway usage --by model, feature, customer, agent, release or environment, with --since and --watch; oneway requests tail shows requests as they land.
03
Your AI assistant, with guard rails
claude mcp add oneway -- npx @oneway-ai/cli mcp lets Claude Code, Cursor or Codex read usage and manage keys and budgets. Every change waits for your approval in the assistant (or is refused, with the command to run, if it can't ask you), keys never reach the model, and the audit log records them.
04
Scripts and CI
Every command takes --json. Set ONEWAY_TOKEN instead of signing in, and export ONEWAY_RELEASE=$(oneway release) in your deploy.
CLI · Example
npx @oneway-ai/cli init
oneway dashboard
oneway usage --by release --since 7d
oneway requests tail
oneway ask "why did spend jump yesterday?"
# In Claude Code
claude mcp add oneway -- npx @oneway-ai/cli mcp
REFERENCE / SWITCHING FROM ANOTHER GATEWAY
Switching from another gateway
Moving an OpenAI- or Anthropic-compatible integration from Portkey, OpenRouter or similar takes a base URL, a key and a few headers.
01
Change the base URL and key
Point your client at https://oneway-gateway.oneway-gateway.workers.dev/v1 with a ONEWAY API key. Request bodies don't change.
02
Bring your provider keys
Add the provider keys you already use under Provider keys. Providers keep billing you directly.
03
Use provider/model IDs
For example openai/gpt-4.1 or anthropic/claude-sonnet-5-5. GET /v1/models lists them.
04
Map metadata and configs to headers
Send x-oneway-customer, x-oneway-feature and x-oneway-agent instead of your gateway's metadata, and x-oneway-fallback and x-oneway-retries instead of its fallback configs.
Switching from another gateway · Example
import OpenAI from "openai";
const ai = new OpenAI({
baseURL: "https://oneway-gateway.oneway-gateway.workers.dev/v1",
apiKey: process.env.ONEWAY_API_KEY,
defaultHeaders: {
"x-oneway-feature": "support-bot",
"x-oneway-fallback": "anthropic/claude-haiku-5-5",
},
});