Make Your First API Call in 5 Minutes
Complete your first API call in five minutes
This guide walks you through obtaining an API key and making your first request in 5 minutes. For registration and login steps, see Console Overview → Register an Account.
The examples in this guide are based on AI Model APIs (Chat, Embeddings, Audio, etc.). For complete API definitions, request parameters, and response formats, see API Reference → AI Model APIs.
Quick Start
Get an API Key
After logging into the console, click "API Keys" in the left sidebar, then click "Create Key" in the top right.
Enter a key name (e.g., my-first-key), leave the other options at their defaults, and click "Submit". The system will generate an API key starting with sk- for calling AI model APIs. For detailed steps, see Create an API Key.
The system will only display the full key once at creation time. Copy and save it somewhere secure immediately.
Get the API Endpoint
The platform's API is fully compatible with the OpenAI API format. Simply replace the Base URL with the platform address:
https://api.tokenopen.ai/v1Make Your First Request
Replace YOUR_API_KEY in the code below with the API key you just created, then run it.
curl https://api.tokenopen.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-5.4-mini",
"messages": [
{
"role": "user",
"content": "Hello, please introduce yourself."
}
]
}'from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.tokenopen.ai/v1",
)
response = client.chat.completions.create(
model="gpt-5.4-mini",
messages=[
{"role": "user", "content": "Hello, please introduce yourself."}
],
)
print(response.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://api.tokenopen.ai/v1",
});
const response = await client.chat.completions.create({
model: "gpt-5.4-mini",
messages: [
{ role: "user", content: "Hello, please introduce yourself." }
],
});
console.log(response.choices[0].message.content);package main
import (
"context"
"fmt"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
)
func main() {
client := openai.NewClient(
option.WithAPIKey("YOUR_API_KEY"),
option.WithBaseURL("https://api.tokenopen.ai/v1"),
)
resp, err := client.Chat.Completions.New(context.Background(), openai.ChatCompletionNewParams{
Model: openai.F("gpt-5.4-mini"),
Messages: openai.F([]openai.ChatCompletionMessageParamUnion{
openai.UserMessage("Hello, please introduce yourself."),
}),
})
if err != nil {
panic(err)
}
fmt.Println(resp.Choices[0].Message.Content)
}API Parameters
| Parameter | Type | Description |
|---|---|---|
model | string | The model to call, e.g., gpt-5.4-mini, claude-sonnet-4-6 |
messages | array | Array of conversation messages; each message has a role and content |
temperature | number | Optional. Controls output randomness; range 0–2, default 1 |
max_tokens | integer | Optional. Caps the maximum number of output tokens |
stream | boolean | Optional. Set to true to enable streaming output |
Streaming Output Example
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.tokenopen.ai/v1",
)
stream = client.chat.completions.create(
model="gpt-5.4-mini",
messages=[{"role": "user", "content": "Write a short poem about spring."}],
stream=True,
)
for chunk in stream:
if chunk.choices[0].delta.content is not None:
print(chunk.choices[0].delta.content, end="", flush=True)import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://api.tokenopen.ai/v1",
});
const stream = await client.chat.completions.create({
model: "gpt-5.4-mini",
messages: [{ role: "user", content: "Write a short poem about spring." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}Common Model Names
| Model | Name |
|---|---|
| GPT-5.5 | gpt-5.5 |
| GPT-5.4 | gpt-5.4 |
| GPT-5.4-mini | gpt-5.4-mini |
| GPT-5.4-nano | gpt-5.4-nano |
| Claude Opus 4.7 | claude-opus-4-7 |
| Claude Sonnet 4.6 | claude-sonnet-4-6 |
| Gemini 3.5 Flash | gemini-3.5-flash |
| Gemini 3.1 Pro | gemini-3.1-pro-preview |
| DeepSeek-V4 Pro | deepseek-v4-pro |
| Qwen3-235B | qwen3-235b-a22b |
For the full model list and real-time pricing, visit the "Pricing" page in the console.
Troubleshooting
| Error Code | Cause | Solution |
|---|---|---|
401 Unauthorized | API key is invalid or malformed | Check that the key is complete and starts with sk- |
403 Forbidden | Current group has no access to this model | Switch to another model or contact support to upgrade your group |
429 Too Many Requests | Rate limit exceeded | Reduce request frequency or apply for a higher-tier group |
402 Payment Required | Insufficient account credits | Go to the Wallet page to top up |
500 Internal Server Error | Upstream service temporarily unavailable | Retry later or switch to another model |
Migrating from OpenAI
The platform is fully compatible with the OpenAI API protocol. Migration requires only two steps — no business logic changes needed.
Step 1: Replace the Base URL
Replace https://api.openai.com in your code or config with https://api.tokenopen.ai.
Step 2: Replace the API Key
Replace your OpenAI sk- key with an API key created in the platform console.
| Original Variable | New Value |
|---|---|
OPENAI_API_KEY | Platform API key (starts with sk-) |
OPENAI_BASE_URL | https://api.tokenopen.ai/v1 |
ANTHROPIC_BASE_URL | https://api.tokenopen.ai |
Once these two steps are complete, your application will route through this platform — no further changes required.
View Call Results
After making a call, go to "Logs" in the console to view real-time details for each request.
| Field | Description |
|---|---|
| Time | Timestamp when the request was made |
| Model | The model used in this call |
| Key Name | The API key name used |
| Input Tokens | Number of input tokens consumed |
| Output Tokens | Number of output tokens generated |
| Credits Used | Credits deducted for this call |
| Status | Success / Failed / Timeout |
For daily or per-model usage trends, visit the "Dashboard" page in the console.
Last updated on