AI Nexus API Reference

OpenAI-compatible · Version 1.0 · Last updated June 2025

Overview

AI Nexus provides an OpenAI-compatible API for all Chinese AI models. If you've used OpenAI's API, you already know how to use ours. Simply change the base URL and API key.

Base URL

https://api.tokencnn.com/v1

Authentication

Include your API key in the Authorization header:

Authorization: Bearer sk-ai-nexus-xxxxxxxx

Get your API key on the AI Nexus homepage. Pay-as-you-go pricing with no hidden fees.

Supported Models

We support all models listed on our Models page. Use the model ID as the model parameter in your requests.

Chat Completions

Create a chat completion. Identical to the OpenAI chat completions API.

POST
/v1/chat/completions

Request Body

{
  "model": "deepseek-v4",
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Hello!"}
  ],
  "temperature": 0.7,
  "max_tokens": 1024
}

Example Response

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1718000000,
  "model": "deepseek-v4",
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "Hello! How can I help you today?"
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 10,
    "total_tokens": 35
  }
}

Streaming

Set stream: true in your request to receive Server-Sent Events (SSE). Each event contains a delta with partial content.

{
  "model": "qwen-max",
  "messages": [{"role": "user", "content": "Tell me a story"}],
  "stream": true
}

Streaming responses use the same format as OpenAI's streaming API.

Parameters

ParameterTypeDefaultDescription
modelstringrequired Model ID to use
messagesarrayrequired Array of message objects
temperaturenumber0.7Sampling temperature (0–2)
max_tokensinteger4096Maximum tokens in response
top_pnumber1.0Nucleus sampling parameter
frequency_penaltynumber0Penalize token frequency (−2 to 2)
presence_penaltynumber0Penalize token presence (−2 to 2)
streambooleanfalseEnable SSE streaming
stopstring/arraynullStop sequences

List Models

GET
/v1/models

Returns a list of all available models. Response format is identical to OpenAI's model list.

{
  "object": "list",
  "data": [
    {"id": "deepseek-v4", "object": "model", "created": 1718000000, "owned_by": "ai-nexus"},
    {"id": "deepseek-v4-flash", "object": "model", ...},
    {"id": "qwen-max", "object": "model", ...}
  ]
}

Check Balance

GET
/v1/balance

Check your account balance and usage statistics.

{
  "balance": 42.50,
  "currency": "USD",
  "total_spent": 157.30,
  "last_updated": "2025-06-17T12:00:00Z"
}

Error Codes

CodeDescription
400Bad request — invalid parameters
401Unauthorized — invalid or missing API key
402Insufficient balance — top up your account
404Model not found — check the model ID
429Rate limit exceeded — slow down requests
500Internal server error

Rate Limits

Rate limits vary by plan. Free tier: 10 RPM. Paid plans scale with usage. Contact us for dedicated throughput.