AIDiscount优汇智
AIDISCOUNT API

One API key for leading AI models

AIDiscount is compatible with the OpenAI and Anthropic APIs. Keep your existing SDK, change the base URL and key, and pick a model from the marketplace.

Quick start

1

Create a key

Sign in, open API Keys and create a key. It starts with sk-.

2

Add balance or a plan

Top up your balance or subscribe to a monthly plan on the Pricing page.

3

Send a request

Copy a model ID from the marketplace and call the API.

curl https://aidiscount.ai/v1/chat/completions \
  -H "Authorization: Bearer $AIDISCOUNT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_MODEL_ID",
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Base URL & auth

ProtocolBase URLAuth header
OpenAIhttps://aidiscount.ai/v1Authorization: Bearer sk-...
Anthropichttps://aidiscount.aix-api-key: sk-...
Geminihttps://aidiscount.ai/v1betax-goog-api-key: sk-...
Keep API keys secret. Call the API from your server, not from browser or mobile code. Store the key in an environment variable such as AIDISCOUNT_API_KEY, and delete any key that may have leaked.

OpenAI-compatible

Works with the official OpenAI SDKs and most tools that accept a custom base URL.

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["AIDISCOUNT_API_KEY"],
    base_url="https://aidiscount.ai/v1",
)

resp = client.chat.completions.create(
    model="YOUR_MODEL_ID",
    messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.AIDISCOUNT_API_KEY,
  baseURL: "https://aidiscount.ai/v1",
});

const resp = await client.chat.completions.create({
  model: "YOUR_MODEL_ID",
  messages: [{ role: "user", content: "Hello" }],
});
console.log(resp.choices[0].message.content);
stream = client.chat.completions.create(
    model="YOUR_MODEL_ID",
    messages=[{"role": "user", "content": "Write a haiku"}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

OpenAI Responses API

The Responses API is OpenAI's newer interface and the one Codex CLI uses. Send input (a string or a list of messages) with optional instructions. The OpenAI SDK returns the reply text as output_text; in raw JSON it is the output[].content[] item whose type is output_text.

curl https://aidiscount.ai/v1/responses \
  -H "Authorization: Bearer $AIDISCOUNT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_MODEL_ID",
    "instructions": "Answer briefly.",
    "input": "Hello"
  }'
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["AIDISCOUNT_API_KEY"],
    base_url="https://aidiscount.ai/v1",
)

resp = client.responses.create(
    model="YOUR_MODEL_ID",
    instructions="Answer briefly.",
    input="Hello",
)
print(resp.output_text)
stream = client.responses.create(
    model="YOUR_MODEL_ID",
    input="Write a haiku",
    stream=True,
)
for event in stream:
    if event.type == "response.output_text.delta":
        print(event.delta, end="", flush=True)

Streaming sends server-sent events such as response.output_text.delta and ends with response.completed. Token counting before a request (POST /v1/responses/input_tokens) is not available for every model; if it returns 404, read token counts from the usage field of the response instead. Which models accept this endpoint depends on your key's group.

Agents over Responses

Agent frameworks that use the Responses API only need a base URL and a key. Set the base URL to https://aidiscount.ai/v1. Tool calls (function calling) work over Responses.

Install with pip install openai-agents. Turn tracing off, otherwise the SDK tries to send traces to OpenAI:

import asyncio, os
from openai import AsyncOpenAI
from agents import (Agent, Runner, function_tool, set_default_openai_api,
                    set_default_openai_client, set_tracing_disabled)

set_default_openai_client(AsyncOpenAI(
    api_key=os.environ["AIDISCOUNT_API_KEY"],
    base_url="https://aidiscount.ai/v1",
), use_for_tracing=False)
set_default_openai_api("responses")
set_tracing_disabled(True)

@function_tool
def get_weather(city: str) -> str:
    """Get the weather for a city."""
    return f"{city}: sunny, 22C"

agent = Agent(
    name="Assistant",
    instructions="Use tools when needed. Answer briefly.",
    model="YOUR_MODEL_ID",
    tools=[get_weather],
)

result = asyncio.run(Runner.run(agent, "What's the weather in Paris?"))
print(result.final_output)

Add a provider to opencode.json. The @ai-sdk/openai package uses Responses; @ai-sdk/openai-compatible uses Chat Completions instead.

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "aidiscount": {
      "npm": "@ai-sdk/openai",
      "name": "AIDiscount",
      "options": {
        "baseURL": "https://aidiscount.ai/v1",
        "apiKey": "{env:AIDISCOUNT_API_KEY}"
      },
      "models": {
        "YOUR_MODEL_ID": { "name": "YOUR_MODEL_ID" }
      }
    }
  }
}

In ~/.openclaw/openclaw.json, set the provider's api to openai-responses:

{
  models: {
    mode: "merge",
    providers: {
      aidiscount: {
        baseUrl: "https://aidiscount.ai/v1",
        apiKey: "${AIDISCOUNT_API_KEY}",
        api: "openai-responses",
        models: [{ id: "YOUR_MODEL_ID", name: "YOUR_MODEL_ID" }],
      },
    },
  },
}

If a tool reports errors over Responses, switch it to Chat Completions (/v1/chat/completions); the same key works for both. Codex CLI setup is under Coding tools.

Anthropic-compatible

Use the Anthropic SDK with the base URL https://aidiscount.ai (without /v1).

import os
import anthropic

client = anthropic.Anthropic(
    api_key=os.environ["AIDISCOUNT_API_KEY"],
    base_url="https://aidiscount.ai",
)

msg = client.messages.create(
    model="YOUR_MODEL_ID",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)
print(msg.content[0].text)
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  apiKey: process.env.AIDISCOUNT_API_KEY,
  baseURL: "https://aidiscount.ai",
});

const msg = await client.messages.create({
  model: "YOUR_MODEL_ID",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hello" }],
});
console.log(msg.content[0].text);
curl https://aidiscount.ai/v1/messages \
  -H "x-api-key: $AIDISCOUNT_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_MODEL_ID",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Gemini-compatible

For the native Gemini API, the auth header is x-goog-api-key and the base URL is https://aidiscount.ai/v1beta.

curl "https://aidiscount.ai/v1beta/models/YOUR_MODEL_ID:generateContent" \
  -H "x-goog-api-key: $AIDISCOUNT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{"parts": [{"text": "Hello"}]}]
  }'

Coding tools

Set these environment variables before running claude:

# macOS / Linux
export ANTHROPIC_BASE_URL="https://aidiscount.ai"
export ANTHROPIC_AUTH_TOKEN="sk-..."

# Windows PowerShell
$env:ANTHROPIC_BASE_URL="https://aidiscount.ai"
$env:ANTHROPIC_AUTH_TOKEN="sk-..."

Add a provider to ~/.codex/config.toml and put your key in AIDISCOUNT_API_KEY:

model_provider = "aidiscount"
model = "YOUR_MODEL_ID"

[model_providers.aidiscount]
name = "AIDiscount"
base_url = "https://aidiscount.ai/v1"
env_key = "AIDISCOUNT_API_KEY"
wire_api = "responses"

With non-OpenAI models such as Claude, Codex prints Model metadata for ... not found. Defaulting to fallback metadata. Requests still work. The warning means Codex doesn't know the model's context size, so add these two lines at the top of config.toml to let Codex compact long sessions at the right point. The values below suit Claude models (200K context). The warning may still appear and can be ignored.

model_context_window = 200000
model_auto_compact_token_limit = 160000

Add AIDiscount as a custom provider in ~/.openclaw/openclaw.json, and put your key in AIDISCOUNT_API_KEY (for example in ~/.openclaw/.env). Claude models use the Anthropic format:

{
  agents: {
    defaults: { model: { primary: "aidiscount/claude-sonnet-4-6" } },
  },
  models: {
    mode: "merge",
    providers: {
      aidiscount: {
        baseUrl: "https://aidiscount.ai",
        apiKey: "${AIDISCOUNT_API_KEY}",
        api: "anthropic-messages",
        models: [{ id: "claude-sonnet-4-6", name: "Claude Sonnet 4.6" }],
      },
    },
  },
}

For GPT models, add a second provider with baseUrl: "https://aidiscount.ai/v1" and api: "openai-completions". Restart the gateway, then run /models to check that the models appear.

For Cursor, Cline, Continue, Cherry Studio and similar tools, choose the OpenAI-compatible provider, set the base URL to https://aidiscount.ai/v1, paste your key and enter a model ID from the marketplace.

Chat apps

Desktop and web chat apps such as Cherry Studio, Chatbox, LobeChat and Open WebUI can use AIDiscount as an OpenAI-compatible provider:

  1. In the app settings, add a custom provider and choose the OpenAI (or OpenAI-compatible) type.
  2. Set the API host or base URL to https://aidiscount.ai/v1. If the app adds /v1 itself, enter https://aidiscount.ai instead.
  3. Paste your sk-... key as the API key.
  4. Add model IDs from the marketplace, such as claude-sonnet-4-6 or gpt-5.5, or use the app's fetch-models button.
If the app reports a 404, the base URL usually has /v1 missing or doubled.

Image generation

Use gpt-image-2 to create images from text, or to edit an image you upload. The image is returned as base64 in data[0].b64_json.

curl https://aidiscount.ai/v1/images/generations \
  -H "Authorization: Bearer $AIDISCOUNT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "A blue city skyline at sunrise",
    "size": "1024x1024"
  }'
curl https://aidiscount.ai/v1/images/edits \
  -H "Authorization: Bearer $AIDISCOUNT_API_KEY" \
  -F model="gpt-image-2" \
  -F image="@photo.png" \
  -F prompt="Make the sky orange"
import base64, os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["AIDISCOUNT_API_KEY"],
    base_url="https://aidiscount.ai/v1",
)

img = client.images.generate(
    model="gpt-image-2",
    prompt="A blue city skyline at sunrise",
    size="1024x1024",
)
with open("out.png", "wb") as f:
    f.write(base64.b64decode(img.data[0].b64_json))
Common size values are 1024x1024, 1536x1024 and 1024x1536. Optional fields such as quality and output_format are passed to the model as-is.

DeepSeek tools

Web search, web page fetch, OCR, text-to-speech and speech recognition from DeepSeek, billed per use. Each tool has its own endpoint, and no model field is needed.

Method & pathRequestPrice
POST /v1/tools/searchWeb search. JSON with query and optional count.$0.429 / 1K calls
POST /v1/tools/fetchFetch a web page as text. JSON with url.$0.429 / 1K calls
POST /v1/tools/ocrRead text from an image or PDF. Multipart file plus purpose=text_recognition.$0.129 / 1K pages
POST /v1/tools/ttsText to speech. JSON with text and voice_id; returns WAV audio.$0.257 / 10K characters
POST /v1/tools/asrSpeech to text. Multipart file; returns text and duration_ms.$0.0669 / hour of audio
curl https://aidiscount.ai/v1/tools/search \
  -H "Authorization: Bearer $AIDISCOUNT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query": "DeepSeek V4", "count": 5}'
curl https://aidiscount.ai/v1/tools/tts \
  -H "Authorization: Bearer $AIDISCOUNT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": "Hello from AIDiscount.", "voice_id": "stella"}' \
  -o out.wav
curl https://aidiscount.ai/v1/tools/asr \
  -H "Authorization: Bearer $AIDISCOUNT_API_KEY" \
  -F [email protected]
curl https://aidiscount.ai/v1/tools/ocr \
  -H "Authorization: Bearer $AIDISCOUNT_API_KEY" \
  -F purpose=text_recognition \
  -F [email protected]
Use an API key in the DeepSeek group. TTS is billed by the characters in text, ASR by seconds of audio, OCR by pages, and search and fetch per call. Failed requests are not billed.

Kimi & GLM

Chat models from Kimi (Moonshot AI) and GLM (Zhipu). Call them like any other chat model: put the model ID in the model field. They work with the OpenAI Chat Completions, Responses and Anthropic Messages formats.

Model IDInput / output (USD per 1M tokens)Context
kimi-k3.1-pro$1.11 / $5.831M
kimi-k3.1-pro-highspeed$2.23 / $11.661M
kimi-k3$1.71 / $8.571M
kimi-k2.7-code$0.557 / $2.31256K
kimi-k2.7-code-highspeed$1.11 / $4.63256K
kimi-k2.6$0.557 / $2.31256K
glm-5.3$0.686 / $2.401M
glm-5.3-prime$1.03 / $3.601M
glm-5.3-flashx$0.171 / $0.601M
glm-5.3-flash$0.069 / $0.241M
curl https://aidiscount.ai/v1/chat/completions \
  -H "Authorization: Bearer $AIDISCOUNT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kimi-k3.1-pro",
    "messages": [{"role": "user", "content": "Hello"}]
  }'
curl https://aidiscount.ai/v1/messages \
  -H "x-api-key: $AIDISCOUNT_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.3",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello"}]
  }'
Use an API key in the Kimi or GLM group, or a key covered by a monthly plan. Cached input is billed at a lower rate. Moonshot plans to retire the K2 models (kimi-k2.6, kimi-k2.7-code) at the end of December 2026, so use kimi-k3.1-pro for new projects.

Embeddings

Turn text into vectors for search and similarity. input takes a string or an array of strings.

curl https://aidiscount.ai/v1/embeddings \
  -H "Authorization: Bearer $AIDISCOUNT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_EMBEDDING_MODEL_ID",
    "input": ["A blue city skyline", "A quiet mountain road"]
  }'

Function calling

Pass function definitions in the OpenAI tools format. The model returns the calls it wants to make in tool_calls. Support depends on the model.

resp = client.chat.completions.create(
    model="YOUR_MODEL_ID",
    messages=[{"role": "user", "content": "What is the weather in Tokyo?"}],
    tools=[{
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get the current weather for a city",
            "parameters": {
                "type": "object",
                "properties": {"city": {"type": "string"}},
                "required": ["city"],
            },
        },
    }],
)
print(resp.choices[0].message.tool_calls)

List models

Get the model IDs your key can use. Use the id field as the model value in requests.

curl https://aidiscount.ai/v1/models \
  -H "Authorization: Bearer $AIDISCOUNT_API_KEY"

Endpoints

Method & pathUse
GET /v1/modelsList models available to your key
POST /v1/chat/completionsOpenAI Chat Completions
POST /v1/responsesOpenAI Responses API
POST /v1/messagesAnthropic Messages
POST /v1/images/generationsImage generation
POST /v1/images/editsImage editing
POST /v1/embeddingsEmbeddings
POST /v1/tools/{tool}DeepSeek tools (search, fetch, ocr, tts, asr)
/v1beta/models/...Gemini native API

Which models and endpoints a key can use depends on its group. Check the marketplace for the current list.

Common parameters

FieldTypeNotes
modelstringModel ID, copied from the marketplace.
messagesarrayConversation messages, each with role and content.
streambooleanSet to true to receive the reply in chunks.
max_tokensintegerLimits the number of tokens in the reply.
temperaturenumberRandomness; lower values give steadier replies.
toolsarrayFunction definitions for function calling.
Request parameters are forwarded to the upstream model as-is, so other OpenAI API fields usually work too, but actual support depends on the model you choose.

Billing & limits

  • Pay as you go: each request is charged to your balance at the model rate shown in the marketplace.
  • Monthly plans: a plan gives a monthly usage quota for 30 days, with a weekly cap. Plan details are on the Pricing page.
  • Usage and charges for every request are listed in your dashboard under Usage.

Errors

HTTPCodeWhat to do
401INVALID_API_KEYThe key is missing, wrong or deleted. Check the header and the key.
403INSUFFICIENT_BALANCETop up your balance or buy a plan.
404—Wrong path or base URL. OpenAI uses /v1; Anthropic does not.
429—Rate limit or plan cap reached. Retry with backoff, or wait for the quota to reset.
5xx—Temporary upstream error. Retry with exponential backoff.

FAQ

Do I have to change my existing code?

No. Point the base URL at AIDiscount and use your AIDiscount key; the rest of your code stays the same.

Is streaming supported?

Yes. Add "stream": true to the request, exactly as with OpenAI.

What should I do if my key leaks?

Delete that key on the API Keys page right away and create a new one. A deleted key stops working immediately.

Where can I see usage and cost?

After signing in, the Usage section of your dashboard shows the model, usage and amount charged for every request.

Help

For account or payment questions, use the contact shown in the site footer. Include the request ID and time of the request. Never send your API key in a support message.