创建聊天补全
为给定的聊天对话创建模型响应。
Authorization
BearerAuth In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/v1/chat/completions" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-3.5-turbo", "messages": [ { "role": "user", "content": "Hello!" } ], "temperature": 1, "max_tokens": 150, "stream": false, "response_format": { "type": "json_object" }, "tools": [ { "type": "function", "function": { "name": "get_weather", "description": "获取指定地点的当前天气", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "城市和州,例如:San Francisco, CA" } }, "required": [ "location" ] } } } ], "tool_choice": "auto" }'{ "choices": [ { "finish_reason": "stop", "index": 0, "message": { "role": "assistant", "content": "I'm doing well, thank you for asking. I am Claude, an AI assistant created by Anthropic." } } ], "created": 1691429984.3852863, "model": "claude-instant-1", "usage": { "prompt_tokens": 18, "completion_tokens": 23, "total_tokens": 41 }, "response_ms": 616.25}