Copy the settings into your app
- API base URL
https://chinagenai.com/v1- Complete chat URL
https://chinagenai.com/v1/chat/completions- Model label
free- API key
- Your ChinaGenAI site key · check key access
Use the base URL in an SDK. Use the complete chat URL only in clients that ask for a full endpoint.
- In your app, choose a custom OpenAI-compatible provider or endpoint.
- Enter the base URL, your site key and
free. If the app asks for the complete Chat Completions URL, usehttps://chinagenai.com/v1/chat/completions. - Send one short test. Confirm it succeeds before connecting a larger workflow.
The model field is a client label, not a promise of a particular model. A prefilled model name is also routed through the same free service. Brand names in our guides help people find information; they do not lock this API to Qwen, a Chinese provider or an overseas provider.
Try a standard request
The cURL example below uses Bash or zsh. For PowerShell, choose PowerShell in the request builder.
curl 'https://chinagenai.com/v1/chat/completions' \
-H 'Authorization: Bearer YOUR_SITE_KEY' \
-H 'Content-Type: application/json' \
-d '{
"model": "free",
"messages": [
{
"role": "user",
"content": "Reply with one short sentence."
}
],
"max_tokens": 256,
"stream": false
}'Replace YOUR_SITE_KEY locally with your site key. The request builder can prepare the command without sending it. Check key availability before sending a request.
Use an OpenAI SDK
Install openai for Python or Node.js, or github.com/openai/openai-go/v3 in an existing Go module. Set the key in your shell, then run one example. The examples do not run a request from this page.
Choose the command for the shell you use.
Save the Node.js example as an .mjs file, or run it in a project configured for ES modules.
macOS or Linux
export CHINAGENAI_API_KEY="YOUR_SITE_KEY"PowerShell
$env:CHINAGENAI_API_KEY="YOUR_SITE_KEY"Python
import os
from openai import OpenAI
client = OpenAI(
base_url="https://chinagenai.com/v1",
api_key=os.environ["CHINAGENAI_API_KEY"],
max_retries=0,
)
reply = client.chat.completions.create(
model="free",
messages=[{"role": "user", "content": "Say hello in one sentence."}],
)
print(reply.choices[0].message.content)Node.js
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://chinagenai.com/v1",
apiKey: process.env.CHINAGENAI_API_KEY,
maxRetries: 0,
});
const reply = await client.chat.completions.create({
model: "free",
messages: [{ role: "user", content: "Say hello in one sentence." }],
});
console.log(reply.choices[0]?.message.content);Go
In an existing Go module, run go get github.com/openai/openai-go/v3. The current Go SDK reference requires Go 1.26 or later; check its version-support notes for older toolchains.
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/option"
)
func main() {
apiKey := os.Getenv("CHINAGENAI_API_KEY")
if apiKey == "" {
log.Fatal("Set CHINAGENAI_API_KEY in your shell first")
}
client := openai.NewClient(
option.WithAPIKey(apiKey),
option.WithBaseURL("https://chinagenai.com/v1"),
option.WithMaxRetries(0),
)
reply, err := client.Chat.Completions.New(context.Background(), openai.ChatCompletionNewParams{
Model: "free",
Messages: []openai.ChatCompletionMessageParamUnion{
openai.UserMessage("Say hello in one sentence."),
},
})
if err != nil {
log.Fatal(err)
}
if len(reply.Choices) == 0 {
log.Fatal("No completion choice returned")
}
fmt.Println(reply.Choices[0].Message.Content)
}These examples disable SDK retries so one call does not automatically repeat after an error. An upstream attempt that fails can still count toward the daily allowance; inspect the error and availability before trying again.
Waiting longer than your Python SDK timeout? See how retries affect the total wait.
Protect your key. Set CHINAGENAI_API_KEY in the server or local shell environment. Never paste it into frontend JavaScript, a public repository or a shared code sample.
USE WHAT YOU ALREADY HAVE
Find your software.
Configuration guides explain the connection and its limits. A compatible URL does not guarantee every app feature.
18 setup routes. Long agent loops can exceed the site's 6-message and 256-token limits.
Connecting a provider directly? Compare free allowances, trials and paid APIs. Gemini and Doubao through Volcengine Ark use their own endpoints and keys.
Compatibility and current limits
Download the OpenAPI starter reference for the short-text request subset, or open the documentation index for agents. These documents describe the route; they do not make a model call.
| Client feature | Current gateway behavior |
|---|---|
| Model discovery | GET /v1/models; the free route appears when the pool is available. |
| Text chat | POST /v1/chat/completions; system, developer, user, assistant and tool messages. |
| Streaming clients | stream: true returns SSE-compatible chunks after the upstream response completes. It does not provide immediate token-by-token delivery. |
| Function tools and JSON mode | Forwarded in the standard chat format; actual model support must pass the upstream activation checks. The gateway does not execute your tools. |
| Browser tools | Bearer-key requests and CORS preflight are supported on /v1/. Account and key-management endpoints remain separate. |
| Other OpenAI products | Responses API, embeddings, images, audio, files and fine-tuning are not exposed by this chat endpoint. Apps that require those APIs need their own supported connection. |
The request fields user, store and metadata are accepted but not forwarded to the upstream model. Check a request body.
When enabled: 20 attempts per network or verified account per UTC day, 1 active request per key, 2 across the site, 48-hour keys, up to 6 messages and 6,000 combined input characters including tool schemas. Requested output is capped at 256 tokens. Long requests may truncate; check finish_reason. Requests accepted for processing count even if the upstream call fails. A separate site-wide daily request cap applies. No ad click or referral is required.
If your app cannot connect
- 401: replace an expired or revoked site key. A provider’s key cannot be used as a site key.
- 400: check the request format, input size and supported endpoint. Preflight a JSON body locally before sending it. Some apps append
/v1automatically; avoid a duplicated path. - 429: wait for an active slot or the next UTC day. Replacing a key does not reset allowance.
- 503: check service availability; paused issuance is not a software configuration error.
- 502: the upstream failed or timed out. There is no automatic paid fallback.