StarMagicStarMagic
English
简体中文简繁體中文繁EnglishEN日本語日EspañolES한국어KO
Integration Guide
GPT-5.1 - 完整参数文档
StarMagicStarMagic
English
简体中文简繁體中文繁EnglishEN日本語日EspañolES한국어KO
TextGPTGPT-5.1

GPT-5.1 - Complete API Reference

  • Use OpenAI SDK format to call GPT-5.1 series models
  • Synchronous processing mode, real-time response
  • Available models: gpt-5.1 (base), gpt-5.1-chat (optimized for conversation), gpt-5.1-thinking (with reasoning output)
  • Text conversation: Single or multi-turn contextual dialogue
  • System prompts: Customize AI role and behavior
  • Multimodal input: Supports text + image mixed input
  • Tool calling: Supports Function Calling
  • Reasoning output: gpt-5.1-thinking returns reasoning_content field showing thought process
<Note> **BaseURL**: The default BaseURL is `https://api.starmagic.ai`, which has better support for text models and long-lived connections. `https://api.starmagic.ai` is the primary endpoint for multimodal services and serves as a fallback address for text models. </Note>

Authorization

AuthorizationstringheaderRequired

All APIs require Bearer Token authentication **Get API Key:** Visit [API Key Management Page](https://starmagic.ai/app/api-keys) to get your API Key **Add to request header:** ``` Authorization: Bearer YOUR_API_KEY ```

Authorization: Bearer YOUR_API_KEY

Request body

application/json
modelenum<gpt-5.1 | gpt-5.1-chat | gpt-5.1-thinking>Required

Model name for chat completion - **gpt-5.1**: Base model for general tasks - **gpt-5.1-chat**: Optimized for conversational tasks - **gpt-5.1-thinking**: Features reasoning capabilities with thinking process output (returns reasoning_content)

"gpt-5.1"
messagesobject[]Required

List of messages for the conversation, supports multi-turn dialogue and multimodal input

[
  {
    "role": "user",
    "content": null
  }
]
streamboolean

Whether to stream the response - `true`: Stream response, returns content chunk by chunk in real-time - `false`: Wait for complete response and return all at once

false
max_tokensinteger

Maximum number of tokens to generate in the response

2000
temperaturenumber

Sampling temperature, controls randomness of output - Lower values (e.g., 0.2): More deterministic and focused output - Higher values (e.g., 1.5): More random and creative output

1
top_pnumber

Nucleus sampling parameter - Controls sampling from tokens with cumulative probability - For example, 0.9 means sampling from tokens with top 90% cumulative probability

0.9
frequency_penaltynumber

Frequency penalty, number between -2.0 and 2.0 - Positive values penalize new tokens based on their frequency in the text

0
presence_penaltynumber

Presence penalty, number between -2.0 and 2.0 - Positive values penalize new tokens based on whether they appear in the text

0
stopobject

Stop sequences, generation stops when these sequences are matched

toolsobject[]

List of tools for Function Calling

[
  {
    "type": "function",
    "function": {
      "name": "get_weather",
      "description": "Get the current weather in a given location",
      "parameters": {}
    }
  }
]

Response

application/json
成功

Response body

idstring

Unique identifier for the chat completion

"chatcmpl-abc123"
modelstring

The model used for completion

"gpt-5.1"
objectenum<chat.completion>

Response type

"chat.completion"
createdinteger

Unix timestamp when the completion was created

1698999496
choicesobject[]

List of completion choices

[
  {
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "Hi there! How can I help you?",
      "reasoning_content": "Let me think about this step by step..."
    },
    "finish_reason": "stop"
  }
]
usageobject

Token usage statistics

{
  "prompt_tokens": 8,
  "completion_tokens": 292,
  "total_tokens": 300
}
POST/v1/chat/completions
curl --request POST \
  --url https://api.starmagic.ai/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "gpt-5.1",
  "messages": [
    {
      "role": "user",
      "content": "Please introduce yourself"
    }
  ],
  "temperature": 1
}'
Response: 成功
{
  "id": "chatcmpl-abc123",
  "model": "gpt-5.1",
  "object": "chat.completion",
  "created": 1698999496,
  "choices": [
    {
      "index": 0,
      "message": {
        "role": null,
        "content": null,
        "reasoning_content": null
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 8,
    "completion_tokens": 292,
    "total_tokens": 300
  }
}

Gemini 3.5 Flash - OpenAI SDK - Full Reference

Previous Page

GPT-5.2 - 快速开始

Next Page