General Model
General Chat Interface (Non-Streaming)
Unified OpenAI Chat Completions compatible endpoint; same route as streaming documentation; successful response is OpenAI raw JSON.
- Route:
POST /v1/chat/completions - This is not a separate interface, just the same route with
stream: false - Successful response is OpenAI raw JSON, without wrapping
code/data
Request Example
curl --request POST \
--url https://api.magickapi.com/v1/chat/completions \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-5",
"stream": false,
"messages": [
{
"role": "system",
"content": "You are a professional AI assistant."
},
{
"role": "user",
"content": "Introduce the history of artificial intelligence."
}
]
}'Successful Response Example
{
"id": "chatcmpl_123",
"object": "chat.completion",
"created": 1712345678,
"model": "gpt-5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The history of artificial intelligence is usually discussed starting from the 1950s."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 28,
"completion_tokens": 20,
"total_tokens": 48
}
}Error Response Example
{
"error": {
"message": "Invalid request",
"type": "invalid_request_error",
"param": null,
"code": "invalid_request"
}
}Authentication
- Request header:
Authorization: Bearer YOUR_API_KEY - For API Key, please use the key generated in the Magick API backend
Common Parameters
model
- Type:
string - Required: Yes
messages
-
Type:
array -
Required: Yes
Consistent with the OpenAI Chat Completions protocol.
stream
-
Type:
boolean -
Recommended fixed value:
falseIf you need to get the complete result at once, please explicitly pass
false.
Other Common Fields
temperaturetop_pmax_tokensmax_completion_tokenstoolstool_choiceresponse_formatreasoning_effort
Compatibility Notes
- Both streaming and non-streaming use
POST /v1/chat/completions
Last updated on
General Chat Interface (Default Streaming)
Unified OpenAI Chat Completions compatible endpoint; same route supports both streaming and non-streaming; successful responses follow the original OpenAI protocol without wrapping code/data.
Claude Messages
Compatible with Claude Messages API; supports system, tools, image content, and streaming events; successful responses follow the original Claude protocol.