Developer docs
Abonnily is an OpenAI-compatible API. If you have used the OpenAI API before, you already know most of this page.
Quickstart
Save your key in an environment variable, then send your first request. Keys always start with the abn- prefix. You get your first one when your account is created after you buy credit, and you can create more from the dashboard. A key is shown in full only once, when it is created.
export ABONNILY_API_KEY="abn-..."curl https://api.abonnily.com/v1/chat/completions \
-H "Authorization: Bearer $ABONNILY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.1-sol",
"messages": [
{"role": "user", "content": "Summarize the benefits of solar energy"}
]
}'Authentication
Send your key in any of the following ways. All of them work on every inference route:
Authorization: Bearer abn-...The default for OpenAI SDKs.x-api-key: abn-...What the Anthropic SDK sends.x-goog-api-key: abn-...What Gemini tools send.?key=abn-...A query parameter, for cases where headers aren't an option.
Base URL
Every OpenAI-compatible inference route starts from this URL:
https://api.abonnily.com/v1The Anthropic SDK and the native Gemini routes append their own path, so pass them the host only: https://api.abonnily.com.
Chat completions
POST /v1/chat/completions accepts the same request body as OpenAI and returns the same response, for every model without exception: GPT, Claude, Gemini, Grok, Kimi, and MiniMax. Just change the value of model.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.abonnily.com/v1",
api_key=os.environ["ABONNILY_API_KEY"],
)
response = client.chat.completions.create(
model="claude-sonnet-5",
messages=[{"role": "user", "content": "Summarize the benefits of solar energy"}],
)
print(response.choices[0].message.content)POST /v1/responses is also available if you use the OpenAI Responses API, with the request and response unchanged.
Streaming
Add "stream": true to receive the answer in chunks as Server-Sent Events. We turn on stream_options.include_usage automatically, so the last chunk before [DONE] carries the usage summary.
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.abonnily.com/v1",
apiKey: process.env.ABONNILY_API_KEY,
});
const stream = await client.chat.completions.create({
model: "gemini-3.1-pro-preview",
messages: [{ role: "user", content: "Summarize the benefits of solar energy" }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}data: {"choices":[{"delta":{"content":"Solar"}}], ...}
data: {"choices":[{"delta":{"content":" energy"}}], ...}
data: {"choices":[], "usage":{"prompt_tokens":21,"completion_tokens":148,"total_tokens":169}}
data: [DONE]choices is empty. Check that it has items before reading choices[0], as the example does.List models
GET /v1/models returns the models available to your key specifically (allowed and enabled), with a display name for each, in a format both OpenAI and Anthropic tooling understand. It accepts the key through any of the authentication methods above. The full public list is in the model catalog.
curl https://api.abonnily.com/v1/models \
-H "Authorization: Bearer $ABONNILY_API_KEY"Using CC Switch
Add Abonnily as a provider in CC Switch and fetch every model your key can use in one click, then pick the ones you want for Claude Code, Codex, or other tools.
- Open CC Switch and add a new provider with custom settings.
- Paste your key, which starts with
abn-, into the API Key field. - Enter the base URL:
https://api.abonnily.comfor Claude Code and Gemini, orhttps://api.abonnily.com/v1for Codex and OpenAI-compatible tools. - Click Fetch Models to list every model your key allows. Pick a model and save the provider.
Anthropic API
POST /v1/messages is a native route in the Anthropic Messages format, for anyone using the Anthropic SDK or its specific features. If you don't send an anthropic-version header, we add 2023-06-01 automatically.
import os
import anthropic
# The SDK appends /v1/messages itself, so pass the host only.
client = anthropic.Anthropic(
base_url="https://api.abonnily.com",
api_key=os.environ["ABONNILY_API_KEY"],
)
message = client.messages.create(
model="claude-opus-5-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hi, introduce yourself."}],
)
print(message.content[0].text)Native Gemini route
Gemini models have two native routes in Google's format: /v1beta/models/{model}:generateContent for standard requests and /v1beta/models/{model}:streamGenerateContent for streaming.
curl "https://api.abonnily.com/v1beta/models/gemini-2.5-flash:generateContent" \
-H "x-goog-api-key: $ABONNILY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"parts": [{"text": "Explain cloud computing in two sentences."}]}]
}'Balance and pricing
Your account has a single prepaid USD balance, shared by all of your keys. Every model has a published price in USD per million input tokens and per million output tokens, listed in the model catalog. The cost of each successful request is calculated as follows, then deducted from your balance:
cost = input_tokens × input_price / 1,000,000
+ output_tokens × output_price / 1,000,000- Cached input tokens are billed at the cached input price when the model has a separate one, and they appear separately in the request log.
- When your balance runs out, the next request is rejected with a
402error and theinsufficient_balancecode before it reaches the provider. The last request may go slightly past your remaining balance, since its size is only known once it completes. - Every response carries an
x-request-idheader and anx-abonnily-balance-remainingheader with your remaining balance in USD. - Some prices are marked as estimated, for models whose official price hasn't been announced yet, and may change later. Requests to a model with no price are rejected with the
model_not_pricedcode. - A key may have a requests-per-minute limit. Go over it and you get a
429response. Wait a moment, then try again.
Top up your balance from the dashboard anytime. No subscription, no auto-renewal.
Errors
Errors use the same format as OpenAI with an appropriate HTTP status code. The code field is the most reliable one to handle in your code.
{
"error": {
"message": "Insufficient balance. Top up at https://abonnily.com/dashboard.",
"type": "insufficient_quota",
"code": "insufficient_balance"
}
}| Status | Code | Meaning |
|---|---|---|
| 401 | invalid_api_keyThe key is missing or invalid. | The key is missing or invalid. |
| 402 | insufficient_balanceYour balance has run out. Top up from the dashboard, then try again. | Your balance has run out. Top up from the dashboard, then try again. |
| 402 | quota_exceededThe key has reached its token cap, if one is set. | The key has reached its token cap, if one is set. |
| 403 | key_disabledThe key is disabled. Enable it from the Keys page in the dashboard. | The key is disabled. Enable it from the Keys page in the dashboard. |
| 403 | key_expiredThe key has passed its expiry date. | The key has passed its expiry date. |
| 403 | model_not_allowedThis key is not allowed to use the requested model. | This key is not allowed to use the requested model. |
| 403 | model_not_pricedThe model has no price yet, so it can't be used until one is published. | The model has no price yet, so it can't be used until one is published. |
| 404 | model_not_foundThe model doesn't exist or isn't currently enabled. | The model doesn't exist or isn't currently enabled. |
| 429 | rate_limitedYou exceeded the key's requests-per-minute limit. | You exceeded the key's requests-per-minute limit. |
| 502 | upstream_errorThe model provider couldn't complete the request. Try again. | The model provider couldn't complete the request. Try again. |