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.

terminal
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.
Never put your key in code that runs in the browser or in mobile apps. Call the API from your server.

Base URL

Every OpenAI-compatible inference route starts from this URL:

base_url
https://api.abonnily.com/v1

The 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.

chat.py
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.

stream.mjs
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 ?? "");
}
response (SSE)
data: {"choices":[{"delta":{"content":"Solar"}}], ...}

data: {"choices":[{"delta":{"content":" energy"}}], ...}

data: {"choices":[], "usage":{"prompt_tokens":21,"completion_tokens":148,"total_tokens":169}}

data: [DONE]
In the last chunk, 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.

terminal
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.

  1. Open CC Switch and add a new provider with custom settings.
  2. Paste your key, which starts with abn-, into the API Key field.
  3. Enter the base URL: https://api.abonnily.com for Claude Code and Gemini, or https://api.abonnily.com/v1 for Codex and OpenAI-compatible tools.
  4. Click Fetch Models to list every model your key allows. Pick a model and save the provider.
The list only shows models your key is allowed to use. Keys you create from the dashboard can reach every enabled model.

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.

terminal
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
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 402 error and the insufficient_balance code 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-id header and an x-abonnily-balance-remaining header 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_priced code.
  • A key may have a requests-per-minute limit. Go over it and you get a 429 response. 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.json
{
  "error": {
    "message": "Insufficient balance. Top up at https://abonnily.com/dashboard.",
    "type": "insufficient_quota",
    "code": "insufficient_balance"
  }
}
StatusCode
401invalid_api_key

The key is missing or invalid.

402insufficient_balance

Your balance has run out. Top up from the dashboard, then try again.

402quota_exceeded

The key has reached its token cap, if one is set.

403key_disabled

The key is disabled. Enable it from the Keys page in the dashboard.

403key_expired

The key has passed its expiry date.

403model_not_allowed

This key is not allowed to use the requested model.

403model_not_priced

The model has no price yet, so it can't be used until one is published.

404model_not_found

The model doesn't exist or isn't currently enabled.

429rate_limited

You exceeded the key's requests-per-minute limit.

502upstream_error

The model provider couldn't complete the request. Try again.