Send Your First Request
Simply replace the base_url with Real200's address and send requests using the same code as OpenAI.
Prerequisitesâ
- API Key created
- Python 3.8+ or Node.js 16+ installed (or use cURL)
Method 1: cURL (No Installation Required)â
curl https://real200.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $REAL200_API_KEY" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello, please introduce Real200."}]
}'
Method 2: Python (Recommended)â
Installâ
pip install openai
Callâ
from openai import OpenAI
client = OpenAI(
api_key="sk-real200-xxxxxxxxxxxxxxxx", # Replace with your Real200 API Key
base_url="https://real200.com/v1" # Just change this line
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello, please introduce Real200."}]
)
print(response.choices[0].message.content)
Environment Variable Methodâ
import os
from openai import OpenAI
# Set environment variables (recommended)
os.environ["OPENAI_API_KEY"] = "sk-real200-xxxxxxxxxxxxxxxx"
os.environ["OPENAI_BASE_URL"] = "https://real200.com/v1"
# Automatically reads environment variables
client = OpenAI()
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}]
)
Method 3: Node.jsâ
Installâ
npm install openai
Callâ
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-real200-xxxxxxxxxxxxxxxx", // Replace with your Real200 API Key
baseURL: "https://real200.com/v1", // Just change this line
});
const response = await client.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Hello, please introduce Real200." }],
});
console.log(response.choices[0].message.content);
Streaming Responseâ
Real200 fully supports streaming responses, suitable for scenarios requiring real-time display of generated content.
from openai import OpenAI
client = OpenAI(
api_key="sk-real200-xxxxxxxxxxxxxxxx",
base_url="https://real200.com/v1"
)
stream = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Write a poem about AI."}],
stream=True # Enable streaming
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
Response Exampleâ
Success Response (200 OK)â
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1716300000,
"model": "gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Real200 is an AI Token gateway platform..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 45,
"total_tokens": 57
}
}
Next Stepsâ
- View Billing Rules for cost details
- Read API Reference for complete endpoints and parameters
- Learn about Smart Routing for automatic provider selection
- Check the Error Code Dictionary for common issue handling
Common Questionsâ
Getting 401 Unauthorized error
- Check if the API Key is correct (starts with
sk-real200-) - Confirm
Authorization: Bearerformat is correct - Confirm the Key hasn't been disabled or deleted
Getting 429 Too Many Requests error
- Your request frequency exceeded the rate limit
- See Rate Limit Strategy for specific limits
- Wait and retry, or contact support to increase quota