Skip to main content
POST
https://api.apimart.ai
/
v1
/
chat
/
completions
curl --request POST \
  --url https://api.apimart.ai/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gpt-4o", # Can be replaced with any supported model ID
    "messages": [
      {
        "role": "system",
        "content": "You are a professional AI assistant."
      },
      {
        "role": "user",
        "content": "Tell me about the history of artificial intelligence."
      }
    ]
  }'
{
  "code": 200,
  "data": {
    "id": "chatcmpl-9876543210",
    "object": "chat.completion",
    "created": 1677652288,
    "model": "gpt-4o",
    "choices": [
      {
        "index": 0,
        "message": {
          "role": "assistant",
          "content": "The history of artificial intelligence (AI) dates back to the 1950s...\n\n1. **Early Period (1950s-1960s)**: The proposal of the Turing Test marked the beginning of AI research...\n\n2. **Expert Systems Era (1970s-1980s)**: Rule-based systems began to be applied in medical diagnosis, financial analysis, and other fields...\n\n3. **Rise of Machine Learning (1990s-2000s)**: Statistical learning methods gradually became mainstream...\n\n4. **Deep Learning Revolution (2010s-Present)**: Breakthroughs in neural network technology brought explosive growth to AI..."
        },
        "finish_reason": "stop"
      }
    ],
    "usage": {
      "prompt_tokens": 28,
      "completion_tokens": 320,
      "total_tokens": 348
    }
  }
}
curl --request POST \
  --url https://api.apimart.ai/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gpt-4o", # Can be replaced with any supported model ID
    "messages": [
      {
        "role": "system",
        "content": "You are a professional AI assistant."
      },
      {
        "role": "user",
        "content": "Tell me about the history of artificial intelligence."
      }
    ]
  }'
{
  "code": 200,
  "data": {
    "id": "chatcmpl-9876543210",
    "object": "chat.completion",
    "created": 1677652288,
    "model": "gpt-4o",
    "choices": [
      {
        "index": 0,
        "message": {
          "role": "assistant",
          "content": "The history of artificial intelligence (AI) dates back to the 1950s...\n\n1. **Early Period (1950s-1960s)**: The proposal of the Turing Test marked the beginning of AI research...\n\n2. **Expert Systems Era (1970s-1980s)**: Rule-based systems began to be applied in medical diagnosis, financial analysis, and other fields...\n\n3. **Rise of Machine Learning (1990s-2000s)**: Statistical learning methods gradually became mainstream...\n\n4. **Deep Learning Revolution (2010s-Present)**: Breakthroughs in neural network technology brought explosive growth to AI..."
        },
        "finish_reason": "stop"
      }
    ],
    "usage": {
      "prompt_tokens": 28,
      "completion_tokens": 320,
      "total_tokens": 348
    }
  }
}

Authorizations

Authorization
string
required
All API endpoints require Bearer Token authenticationGet your API Key:Visit the API Key Management Page to get your API KeyAdd it to the request header:
Authorization: Bearer YOUR_API_KEY

Body

model
string
required
Model nameSupported models include:
  • OpenAI: gpt-5, gpt-5-chat-latest, gpt-5-mini, gpt-5-nano, gpt-5-pro
  • Anthropic: claude-sonnet-4-5-20250929, claude-opus-4-1-20250805, claude-haiku-4-5-20251001, claude-opus-4-1-20250805-thinking, claude-sonnet-4-5-20250929-thinking
  • Google: gemini-2.5-pro, gemini-2.5-flash, gemini-2.5-pro-thinking, gemini-2.5-flash-lite
  • DeepSeek: deepseek-v3.1-250821, deepseek-v3.1-think-250821, deepseek-v3-0324
  • Doubao: doubao-seed-1-6-251015, doubao-seed-1-6-flash-250828, doubao-seed-1-6-thinking-250715
  • More models being added continuously…
messages
array
required
List of conversation messagesExample:
[{"role": "user", "content": "Hello, please introduce yourself"}]
Advanced usage:Add system prompt (to define AI behavior):
[
  {"role": "system", "content": "You are a professional Python tutor"},
  {"role": "user", "content": "How do I learn programming?"}
]
Multi-turn conversation (with context):
[
  {"role": "user", "content": "Hello"},
  {"role": "assistant", "content": "Hi! How can I help you?"},
  {"role": "user", "content": "Tell me about AI"}
]
Role descriptions:
  • user: User message (use this most of the time)
  • system: System prompt to set AI behavior and role
  • assistant: AI’s previous responses, used for conversation context
temperature
number
Controls output randomness, range 0-2
  • Lower values (e.g., 0.2) make output more deterministic
  • Higher values (e.g., 1.8) make output more random
Default: 1.0
max_tokens
integer
Maximum number of tokens to generateDifferent models have different maximum limits, please refer to specific model documentation
stream
boolean
Whether to use streaming output
  • true: Streaming response (SSE format)
  • false: Complete response at once
Default: false
top_p
number
Nucleus sampling parameter, range 0-1Controls diversity of generated text, recommend using either this or temperatureDefault: 1.0
frequency_penalty
number
Frequency penalty, range -2.0 to 2.0Positive values reduce the likelihood of repeating the same wordsDefault: 0
presence_penalty
number
Presence penalty, range -2.0 to 2.0Positive values increase the likelihood of talking about new topicsDefault: 0
stop
string or array
Stop sequencesUp to 4 sequences where generation will stop when encountered
n
integer
Number of completions to generateDefault: 1⚠️ Note: Must enter a plain number (e.g., 1), do not use quotes or it will cause an error

Response

id
string
Unique identifier for the response
object
string
Object type, fixed as chat.completion
created
integer
Creation timestamp
model
string
The actual model name used
choices
array
List of generated responses
usage
object
Token usage statistics

Supported Models

OpenAI Series

  • gpt-5 - GPT-5 base model
  • gpt-5-chat-latest - GPT-5 latest chat version
  • gpt-5-mini - GPT-5 lightweight version, cost-effective
  • gpt-5-nano - GPT-5 ultra-lightweight version
  • gpt-5-pro - GPT-5 professional enhanced version

Anthropic Series

  • claude-haiku-4-5-20251001 - Claude 4.5 fast response version
  • claude-sonnet-4-5-20250929 - Claude 4.5 balanced version
  • claude-opus-4-1-20250805 - Most powerful Claude 4.1 flagship model
  • claude-opus-4-1-20250805-thinking - Claude 4.1 Opus deep thinking version
  • claude-sonnet-4-5-20250929-thinking - Claude 4.5 Sonnet deep thinking version

Google Series

  • gemini-2.5-flash - Gemini 2.5 fast version
  • gemini-2.5-pro - Gemini 2.5 professional version
  • gemini-2.5-flash-lite - Gemini 2.5 ultra-lightweight version
  • gemini-2.5-pro-thinking - Gemini 2.5 Pro deep thinking version

DeepSeek Series

  • deepseek-v3.1-250821 - DeepSeek V3.1 base version
  • deepseek-v3.1-think-250821 - DeepSeek V3.1 thinking version
  • deepseek-v3-0324 - DeepSeek V3 standard version

Doubao Series

  • doubao-seed-1-6-flash-250828 - Doubao Seed 1.6 fast version
  • doubao-seed-1-6-thinking-250715 - Doubao Seed 1.6 thinking version
  • doubao-seed-1-6-251015 - Doubao Seed 1.6 standard version

Usage Examples

Basic Conversation

{
  "model": "gpt-4o",
  "messages": [
    {"role": "user", "content": "Hello"}
  ]
}

System Prompt

{
  "model": "claude-3-5-sonnet",
  "messages": [
    {"role": "system", "content": "You are a professional Python programming tutor"},
    {"role": "user", "content": "How to use list comprehensions?"}
  ]
}

Multi-turn Conversation

{
  "model": "gemini-2.0-flash",
  "messages": [
    {"role": "user", "content": "What is machine learning?"},
    {"role": "assistant", "content": "Machine learning is a branch of artificial intelligence..."},
    {"role": "user", "content": "Can you give me an example?"}
  ]
}

Streaming Output

{
  "model": "gpt-4o",
  "messages": [
    {"role": "user", "content": "Write a poem about spring"}
  ],
  "stream": true
}