1. 对话(openai, gemini, claude, deepseek...)
xaix
  • (必读)使用说明
  • 列出模型
    • Models(列出模型)
      GET
  • OpenAI 格式(支持各大原厂模型)
    • 对话(openai, gemini, claude, deepseek...)
      • 聊天(chat)
        POST
      • 聊天(responses)
        POST
      • 流式返回(chat)
        POST
      • 流式返回(responses)
        POST
      • 思考模式(chat)
        POST
      • 思考模式(responses)
        POST
      • MCP调用(chat)
        POST
      • web search(chat)
        POST
      • web search(responses)
        POST
      • 工具调用(chat)
        POST
      • 结构化输出(chat)
        POST
    • 图像(gpt, dalle, banana, jimeng)
      • 参考图片(chat)
      • 参考图片(images)
      • 分析图片(chat)
      • 生成图片(chat)
      • 生成图片(images)
    • 视频(sora, veo, 可灵)
      • 查询视频状态 (sora, veo)
      • 获取视频内容 (sora, veo)
      • 首尾帧视频-同步 (veo)
      • 首尾帧生视频-异步 (可灵)
      • 图生视频-同步 (veo)
      • 图生视频-异步 (sora, veo)
      • 图生视频-异步 (可灵)
      • 文生视频-同步 (veo)
      • 文生视频-异步 (sora, veo)
      • 文生视频-异步 (可灵)
    • 向量化
      • 文本向量化
    • 语音
      • 语音合成(audio)
      • 语音回复(chat)
      • 语音识别(audio)
  • Anthropic 格式
    • Anthropic SDK使用指南
    • 聊天
      POST
    • 聊天(prompt cache)
      POST
    • 流式返回
      POST
    • 聊天(深度思考)
      POST
    • 工具调用(function call)
      POST
    • 分析图片
      POST
  • Gemini 格式
    • 聊天
      POST
    • 生成图片(nano banana)
      POST
    • 分析图片
      POST
    • 编辑图片(nano banana)
      POST
  • Midjourney 格式
    • 上传(upload)
    • 按钮点击(Action)
    • 换脸(FaceSwap)
    • 获取种子(Seed)
    • 任务查询接口
    • 任务批量查询接口
    • 图片融合(Blend)
    • 图生文(Describe)
    • 文生图(Imagine)
  1. 对话(openai, gemini, claude, deepseek...)

工具调用(chat)

POST
/v1/chat/completions
使用function call
如果使用非openai模型,则令牌需要使用对应的分组,比如使用claude模型,则令牌分组需要选择claude

请求参数

Header 参数

Body 参数application/json

示例
{
    "model": "gpt-4o-2024-08-06",
    "messages": [
        {
            "role": "user",
            "content": "What's the weather like in Boston today?"
        }
    ],
    "tools": [
        {
            "type": "function",
            "function": {
                "name": "get_current_weather",
                "description": "Get the current weather in a given location",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "location": {
                            "type": "string",
                            "description": "The city and state, e.g. San Francisco, CA"
                        },
                        "unit": {
                            "type": "string",
                            "enum": [
                                "celsius",
                                "fahrenheit"
                            ]
                        }
                    },
                    "required": [
                        "location"
                    ]
                }
            }
        }
    ]
}

请求示例代码

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.xaix.me/v1/chat/completions' \
--header 'Authorization: Bearer {YOUR_API_KEY}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "gpt-4o-2024-08-06",
    "messages": [
        {
            "role": "user",
            "content": "What'\''s the weather like in Boston today?"
        }
    ],
    "tools": [
        {
            "type": "function",
            "function": {
                "name": "get_current_weather",
                "description": "Get the current weather in a given location",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "location": {
                            "type": "string",
                            "description": "The city and state, e.g. San Francisco, CA"
                        },
                        "unit": {
                            "type": "string",
                            "enum": [
                                "celsius",
                                "fahrenheit"
                            ]
                        }
                    },
                    "required": [
                        "location"
                    ]
                }
            }
        }
    ]
}'

返回响应

🟢200成功
application/json
Body

示例
{
    "id": "string",
    "object": "string",
    "created": 0,
    "model": "string",
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "string",
                "content": null,
                "tool_calls": [
                    {
                        "id": "string",
                        "type": "string",
                        "function": {
                            "name": "string",
                            "arguments": "string"
                        }
                    }
                ],
                "refusal": null,
                "annotations": [
                    "string"
                ]
            },
            "logprobs": null,
            "finish_reason": "string"
        }
    ],
    "usage": {
        "prompt_tokens": 0,
        "completion_tokens": 0,
        "total_tokens": 0,
        "prompt_tokens_details": {
            "cached_tokens": 0,
            "audio_tokens": 0
        },
        "completion_tokens_details": {
            "reasoning_tokens": 0,
            "audio_tokens": 0,
            "accepted_prediction_tokens": 0,
            "rejected_prediction_tokens": 0
        }
    },
    "system_fingerprint": "string"
}
修改于 2026-04-13 02:38:01
上一页
web search(responses)
下一页
结构化输出(chat)
Built with