OpenAI-format API
Flash API exposes a fully OpenAI-compatible API. It supports every GPT model, plus other models that speak the OpenAI format.
Endpoint
https://ai.flashapi.top/v1Authentication
Add your API key to the request header:
Authorization: Bearer YOUR_API_KEYChat Completions
Overview
The core text endpoint for single-turn and multi-turn conversations.
Endpoint
POST /v1/chat/completionsImportant
GPT, Claude, Gemini and other text models all support both streaming and non-streaming output. Use "stream": false for short requests or one-shot structured results. For long answers and interactive UIs, use "stream": true so content shows up sooner.
Request examples
GPT model (non-streaming)
curl https://ai.flashapi.top/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-6.1-sol",
"messages": [
{
"role": "system",
"content": "You are a helpful AI assistant"
},
{
"role": "user",
"content": "Write a quicksort in Python"
}
],
"stream": false,
"temperature": 0.7,
"max_tokens": 2000
}'Claude model (non-streaming)
curl https://ai.flashapi.top/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "claude-opus-5-5",
"messages": [
{
"role": "user",
"content": "Hello!"
}
],
"stream": false,
"temperature": 0.7
}'Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model name, e.g. gpt-6.1-sol |
| messages | array | Yes | List of conversation messages |
| stream | boolean | No | true returns an SSE stream, false returns the full JSON. Supported by all text models |
| temperature | number | No | Sampling temperature, 0–2. Defaults to 1 |
| max_tokens | integer | No | Maximum number of tokens to generate |
| top_p | number | No | Nucleus sampling, 0–1 |
| stop | string/array | No | Stop sequences |
| stream_options | object | No | Streaming options |
Messages format
{
"messages": [
{
"role": "system",
"content": "System prompt"
},
{
"role": "user",
"content": "User message"
},
{
"role": "assistant",
"content": "Assistant reply"
}
]
}Roles:
system: the system prompt that sets the model's behavioruser: the user's messageassistant: the model's reply (for multi-turn conversations)
Response format
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "gpt-6.1-sol",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "This is the model's reply"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 56,
"completion_tokens": 31,
"total_tokens": 87
}
}Streaming
Every text model can stream. Set stream to true and the server keeps sending SSE events.
GPT model streaming request (optional)
curl https://ai.flashapi.top/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-6.1-sol",
"messages": [{"role": "user", "content": "Hi"}],
"stream": true,
"stream_options": {
"include_usage": true
}
}'Streaming response format (SSE)
data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1677652288,"model":"gpt-6.1-sol","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}
data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1677652288,"model":"gpt-6.1-sol","choices":[{"index":0,"delta":{"content":"Hi"},"finish_reason":null}]}
data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1677652288,"model":"gpt-6.1-sol","choices":[{"index":0,"delta":{"content":" there"},"finish_reason":null}]}
data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1677652288,"model":"gpt-6.1-sol","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":9,"completion_tokens":2,"total_tokens":11}}
data: [DONE]Claude model non-streaming request
curl https://ai.flashapi.top/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "claude-opus-5-5",
"messages": [{"role": "user", "content": "Hi"}],
"stream": false
}'Supported models
GPT family
| Model | Description | Context | Output |
|---|---|---|---|
| gpt-6.1-sol | Current recommended model | 1M | Streaming or non-streaming |
Check GET /v1/models with your group's key and the console for available models.
Claude family (OpenAI format, streaming optional)
| Model | Description | Context | Streaming |
|---|---|---|---|
| claude-opus-5-5 | Current recommended Claude | 1M | Optional |
Gemini family (OpenAI format, streaming optional)
| Model | Description | Context | Streaming |
|---|---|---|---|
| gemini-3.1-pro-preview | Recommended Gemini Pro model | 1M | Optional |
| gemini-3.8-flash | Recommended Gemini Flash model | 1M | Optional |
Code examples
Python (GPT model, streaming)
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://ai.flashapi.top/v1"
)
# Stream long answers
stream = client.chat.completions.create(
model="gpt-6.1-sol",
messages=[
{"role": "system", "content": "You are a coding assistant"},
{"role": "user", "content": "Write a Python function that computes the Fibonacci sequence"}
],
stream=True,
stream_options={"include_usage": True}
)
for chunk in stream:
if chunk.choices:
content = chunk.choices[0].delta.content
if content is not None:
print(content, end="")
# Usage stats (in the last chunk)
if hasattr(chunk, 'usage') and chunk.usage:
print(f"\n\nUsed {chunk.usage.total_tokens} tokens")Python (non-streaming, works with every text model)
# GPT, Claude and Gemini all support non-streaming requests
response = client.chat.completions.create(
model="claude-opus-5-5",
messages=[
{"role": "user", "content": "Write a quicksort algorithm"}
],
stream=False
)
print(response.choices[0].message.content)Node.js (GPT model, streaming)
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'YOUR_API_KEY',
baseURL: 'https://ai.flashapi.top/v1'
});
async function main() {
// Stream long answers
const stream = await client.chat.completions.create({
model: 'gpt-6.1-sol',
messages: [
{ role: 'system', content: 'You are a coding assistant' },
{ role: 'user', content: 'Write a quicksort algorithm' }
],
stream: true,
stream_options: { include_usage: true }
});
for await (const chunk of stream) {
if (chunk.choices[0]?.delta?.content) {
process.stdout.write(chunk.choices[0].delta.content);
}
// Usage stats
if (chunk.usage) {
console.log(`\n\nUsed ${chunk.usage.total_tokens} tokens`);
}
}
}
main();Node.js (non-streaming)
// Every text model can be called without streaming
async function callClaude() {
const completion = await client.chat.completions.create({
model: 'claude-opus-5-5',
messages: [
{ role: 'user', content: 'Write a quicksort algorithm' }
],
stream: false
});
console.log(completion.choices[0].message.content);
}cURL (GPT model)
# GPT models can stream too
curl https://ai.flashapi.top/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-6.1-sol",
"messages": [
{"role": "user", "content": "Hello!"}
],
"stream": true,
"stream_options": {
"include_usage": true
}
}'cURL (Claude, non-streaming)
# Claude model, non-streaming
curl https://ai.flashapi.top/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "claude-opus-5-5",
"messages": [
{"role": "user", "content": "Hello!"}
],
"stream": false
}'Error handling
Error response format
{
"error": {
"message": "Error description",
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}Common error codes
| Status | Error type | Description |
|---|---|---|
| 401 | invalid_api_key | Invalid API key |
| 429 | rate_limit_exceeded | Rate limit exceeded |
| 500 | server_error | Server error |
| 503 | service_unavailable | Service unavailable |
Error handling example
from openai import OpenAI, APIConnectionError, APIStatusError, APIError
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://ai.flashapi.top/v1"
)
try:
# Stream so output shows up as it's generated
stream = client.chat.completions.create(
model="gpt-6.1-sol",
messages=[{"role": "user", "content": "Hello"}],
stream=True
)
for chunk in stream:
if chunk.choices:
content = chunk.choices[0].delta.content
if content:
print(content, end="")
except APIConnectionError as e:
print(f"Connection failed: {e}")
except APIStatusError as e:
print(f"HTTP status: {e.status_code}")
print(f"Error response: {e.body}")
except APIError as e:
print(f"API error: {e}")Best practices
1. Set a sensible timeout
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://ai.flashapi.top/v1",
timeout=30.0 # 30-second timeout
)2. Add retries
from tenacity import retry, stop_after_attempt, wait_exponential
@retry(
stop=stop_after_attempt(3),
wait=wait_exponential(multiplier=1, min=4, max=10)
)
def call_api():
return client.chat.completions.create(...)3. Stream when it makes sense
Every text model supports both streaming and non-streaming. Stream long answers; use non-streaming for short requests and structured results:
# GPT model, streaming
stream = client.chat.completions.create(
model="gpt-6.1-sol",
messages=[{"role": "user", "content": "Write an article"}],
stream=True,
stream_options={"include_usage": True}
)
for chunk in stream:
if chunk.choices:
content = chunk.choices[0].delta.content
if content:
print(content, end='')
# Claude model, non-streaming
response = client.chat.completions.create(
model="claude-opus-5-5",
messages=[{"role": "user", "content": "Write an article"}],
stream=False
)
print(response.choices[0].message.content)4. Keep token usage in check
response = client.chat.completions.create(
model="gpt-6.1-sol",
messages=[...],
max_tokens=500, # Cap output length
temperature=0.3 # Less randomness
)
# Check token usage
print(f"Used {response.usage.total_tokens} tokens")Next steps
- Anthropic-format API: the native Claude format
- Pricing: what it costs
- Get help: reach us when something breaks