跳转到主要内容
POST
/
chat
/
completions
Curl
curl https://aihubmix.com/v1/chat/completions \
  -H "Authorization: Bearer AIHUBMIX_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"model\": \"gpt-3.5-turbo\",\"messages\": [{\"role\": \"user\", \"content\": \"Hello\"}]}"
{
  "choices": [
    {
      "message": {
        "role": "<string>",
        "content": "<string>"
      },
      "finish_reason": "<string>"
    }
  ],
  "usage": {
    "prompt_tokens": 123,
    "completion_tokens": 123,
    "total_tokens": 123
  }
}
The API Playground provides a sandbox environment for real-time request testing and intuitive response data visualization.
For code security, we recommend:
  1. Managing sensitive information (such as API Keys) through environment variables. For Python calls, use os.getenv("AIHUBMIX_API_KEY").
  2. Avoiding printing sensitive information in logs/outputs.
  3. Preventing key leakage by adding .env to .gitignore to keep secrets out of the code repository.

授权

Authorization
string
header
必填

Bearer authentication. Add Authorization: Bearer AIHUBMIX_API_KEY in request headers. Get your API key here.

请求体

application/json
model
string
必填

Model ID to use. Check in the Model Hub.

messages
object[]
必填

Conversation messages including role and content.

temperature
number
默认值:0.8

Sampling temperature (0-2). Higher values yield more randomness.

max_tokens
integer
默认值:1024

Maximum number of tokens to generate (depends on model).

top_p
number
默认值:1

Top-p nucleus sampling parameter controlling diversity.

frequency_penalty
number
默认值:0

Frequency penalty to reduce repetition.

presence_penalty
number
默认值:0

Presence penalty to encourage new topics.

stream
boolean
默认值:false

Enable streaming responses for real-time output.

web_search_options
object

Web search options (only supported by specific search models).

响应

Successful response

choices
object[]
usage
object