1. 聊天模型(Chat)
91model
  • 接口地址与 API KEY获取方式
  • 前言-模型兼容性(必读)
  • OpenAI官方SDK使用教程
  • 高并发批量请求示例
  • Claude Code最佳API配置教程指南
  • OpenAi Codex最佳API配置教程指南
  • Gemini CLI最佳API配置教程指南
  • OpenClaw 配置使用 API 教程
  • OpenCode 配置使用 API 教程
  • 模型信息
    • 列出可用模型
      GET
    • 列出单个模型
      GET
  • OpenClaw 专栏
    • 技能:OpenClaw接入vapi的nao-banana、gpt-image生图
  • 聊天模型(Chat)
    • /v1/chat/completions
      POST
    • 聊天接口(图片分析)
      POST
    • 聊天接口(函数调用)
      POST
    • 聊天接口(o1-o3系列模型)
      POST
    • Claude (OpenAI格式)-可PDF分析
      POST
    • Claude (原生格式)-可PDF分析
      POST
    • Gemini (OpenAI格式)-可文件分析
      POST
  • 应用手册
    • 1. OpenClaw
    • 2. Chatbox
    • 3. IntelliJ IDEA(PyCharm)
    • 4. Cursor
    • 5. Trae
    • 6. CherryStudio
    • 7. Dify
    • 8. AingDesk
    • 9. VS Code
    • 10. Zed
    • 11. DeepChat
    • 12. Sider
    • 13. ChatWise
    • 14. Glarity
    • 15. WPS
  • 程序中如何使用
    • 1. Python
    • 2. nodejs
  1. 聊天模型(Chat)

聊天接口(函数调用)

开发中
POST
/v1/chat/completions

请求参数

Authorization
在 Header 添加参数
Authorization
,其值为在 Bearer 之后拼接 Token
示例:
Authorization: Bearer ********************
Header 参数

Body 参数application/json必填

示例
{
    "model": "gpt-4o",
    "messages": [
        {
            "role": "user",
            "content": "What is the weather like in Paris today?"
        }
    ],
    "tools": [
        {
            "type": "function",
            "function": {
                "name": "get_weather",
                "description": "Get current temperature for a given location.",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "location": {
                            "type": "string",
                            "description": "City and country e.g. Bogotá, Colombia"
                        }
                    },
                    "required": [
                        "location"
                    ],
                    "additionalProperties": false
                },
                "strict": true
            }
        }
    ]
}

请求示例代码

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location '/v1/chat/completions' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
    "model": "gpt-4o",
    "messages": [
        {
            "role": "user",
            "content": "What is the weather like in Paris today?"
        }
    ],
    "tools": [
        {
            "type": "function",
            "function": {
                "name": "get_weather",
                "description": "Get current temperature for a given location.",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "location": {
                            "type": "string",
                            "description": "City and country e.g. Bogotá, Colombia"
                        }
                    },
                    "required": [
                        "location"
                    ],
                    "additionalProperties": false
                },
                "strict": true
            }
        }
    ]
}'

返回响应

🟢200成功
application/json
Bodyapplication/json

示例
{
    "id": "chatcmpl-Ax2bU1RFE8P0Y9uqKcErQNLcx4dDe",
    "object": "chat.completion",
    "created": 1738634724,
    "model": "gpt-4o-2024-08-06",
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": null,
                "tool_calls": [
                    {
                        "id": "call_FezxjoWuDV1CL3dITVFOjUzK",
                        "type": "function",
                        "function": {
                            "name": "get_weather",
                            "arguments": "{\"location\":\"Paris, France\"}"
                        }
                    }
                ],
                "refusal": null
            },
            "logprobs": null,
            "finish_reason": "tool_calls"
        }
    ],
    "usage": {
        "prompt_tokens": 65,
        "completion_tokens": 16,
        "total_tokens": 81,
        "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": "fp_f3927aa00d"
}
修改于 2026-05-26 01:30:12
上一页
聊天接口(图片分析)
下一页
聊天接口(o1-o3系列模型)
Built with