Skip to main content
POST
/
chat
/
completions
Create chat completion
curl --request POST \
  --url https://api.aiearth.dev/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "gpt-4o-mini",
  "messages": [
    {
      "role": "system",
      "content": "You are a concise assistant."
    },
    {
      "role": "user",
      "content": "用一句话介绍 AIOAGI。"
    }
  ],
  "temperature": 0.7
}
'
{
  "id": "<string>",
  "object": "chat.completion",
  "created": 123,
  "model": "<string>",
  "choices": [
    {
      "index": 123,
      "message": {
        "role": "system",
        "content": "<string>"
      },
      "finish_reason": "<string>"
    }
  ],
  "usage": {
    "prompt_tokens": 123,
    "completion_tokens": 123,
    "total_tokens": 123
  }
}
使用 OpenAI 兼容请求体发起多轮对话、文本生成、代码生成或推理任务。

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
model
string
required

Model name available in your AIOAGI account.

messages
object[]
required
temperature
number
default:1
Required range: 0 <= x <= 2
max_tokens
integer
Required range: x >= 1
stream
boolean
default:false

Response

Chat completion response

id
string
object
string
Example:

"chat.completion"

created
integer
model
string
choices
object[]
usage
object