### Python 调用 EveryLinks 聊天补全 Source: https://tokens.everylinks.com/docs 使用 OpenAI Python SDK 调用 EveryLinks 的 OpenAI 兼容接口。需要先注册账户并获取 API Key,将 替换为实际密钥。 ```python from openai import OpenAI client = OpenAI( base_url="https://gw.everylinks.com/v1", api_key="" ) completion = client.chat.completions.create( model="doubao/doubao-seed-2.0-pro", messages=[ {"role": "user", "content": "你好,请介绍一下自己"} ] ) print(completion.choices[0].message.content) ``` -------------------------------- ### HTTP 请求聊天补全接口 Source: https://tokens.everylinks.com/docs 向 /v1/chat/completions 发送 POST 请求,使用 OpenAI 兼容的请求体。支持所有 OpenAI 参数,如 temperature、top_p、max_tokens、tools、response_format 等。 ```http POST /v1/chat/completions { "model": "doubao/doubao-seed-2.0-pro", "messages": [ {"role": "system", "content": "你是一个有用的助手。"}, {"role": "user", "content": "你好!"} ], "temperature": 0.7, "max_tokens": 1000, "stream": false } ``` -------------------------------- ### POST /v1/chat/completions Source: https://tokens.everylinks.com/docs Creates a chat completion using the OpenAI-compatible interface. This endpoint accepts a list of messages and model parameters, and returns a completion response. ```APIDOC ## POST /v1/chat/completions ### Description Creates a chat completion using the OpenAI-compatible interface. This endpoint accepts a list of messages and model parameters, and returns a completion response. ### Method POST ### Endpoint /v1/chat/completions ### Parameters #### Request Body - **model** (string) - Required - The model identifier, e.g., "doubao/doubao-seed-2.0-pro". - **messages** (array) - Required - An array of message objects with role and content. - **temperature** (number) - Optional - Sampling temperature, e.g., 0.7. - **max_tokens** (integer) - Optional - Maximum number of tokens to generate. - **stream** (boolean) - Optional - If true, uses streaming response. - **top_p** (number) - Optional - Nucleus sampling parameter. Supported. - **tools** (array) - Optional - Tool definitions for function calling. Supported. - **response_format** (object) - Optional - Response format specification. Supported. ### Request Example { "model": "doubao/doubao-seed-2.0-pro", "messages": [ {"role": "system", "content": "你是一个有用的助手。"}, {"role": "user", "content": "你好!"} ], "temperature": 0.7, "max_tokens": 1000, "stream": false } ### Response #### Success Response (200) The response is a chat completion object with choices containing the generated message content. #### Response Example { "choices": [ { "message": { "role": "assistant", "content": "你好!有什么我可以帮助你的吗?" } } ] } ``` -------------------------------- ### curl 流式输出聊天补全 Source: https://tokens.everylinks.com/docs 使用 curl 发起流式聊天补全请求,设置 stream: true 以接收 SSE 事件流。流式请求同样会计费。 ```bash curl https://gw.everylinks.com/v1/chat/completions \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "model": "doubao/doubao-seed-2.0-pro", "messages": [{"role": "user", "content": "你好"}], "stream": true }' ``` -------------------------------- ### POST /v1/chat/completions (streaming) Source: https://tokens.everylinks.com/docs Streams chat completions using Server-Sent Events (SSE) by setting the stream parameter to true. This allows real-time token delivery. ```APIDOC ## POST /v1/chat/completions (streaming) ### Description Streams chat completions using Server-Sent Events (SSE) by setting the stream parameter to true. This allows real-time token delivery. ### Method POST ### Endpoint /v1/chat/completions ### Parameters #### Query Parameters None documented. #### Request Body - **model** (string) - Required - The model identifier. - **messages** (array) - Required - An array of message objects. - **stream** (boolean) - Required - Must be true to enable streaming. ### Request Example curl https://gw.everylinks.com/v1/chat/completions \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "model": "doubao/doubao-seed-2.0-pro", "messages": [{"role": "user", "content": "你好"}], "stream": true }' ### Response #### Success Response An SSE stream of completion events. #### Response Example No static example provided; the response is streamed as SSE events. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.