Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
FocusAPI Chat Completions 附录参考:POST /v1/chat/completions 端点、请求字段、流式输出和响应结构。
POST /v1/chat/completions
https://www.focusapi.cn/v1
Authorization
Bearer sk-your-api-key
Content-Type
application/json
model
messages
role
system
user
assistant
stream
true
temperature
max_tokens
{ "model": "gpt-4o-mini", "messages": [ { "role": "user", "content": "你好" } ] }
"stream": true
data:
stream = client.chat.completions.create( model="gpt-4o-mini", messages=[{"role": "user", "content": "你好"}], stream=True, ) for chunk in stream: if chunk.choices[0].delta.content: print(chunk.choices[0].delta.content, end="")
{ "id": "chatcmpl-xxx", "object": "chat.completion", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "..." }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 10, "completion_tokens": 20, "total_tokens": 30 } }
usage