Yunhai AI platform · One API, multiple modelsView offers
Yunhai
DocsConsoleEN / 中Sign in
DocumentationChat Completions

Chat Completions

Use a message list for multi-turn text conversations.

Endpoint

http
POST /v1/chat/completions

Example request

bash
curl http://localhost:3187/v1/chat/completions \
  -H "Authorization: Bearer $YUNHAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"YOUR_MODEL_ID","messages":[{"role":"user","content":"Hello"}]}'

Main parameters

FieldDescription
modelAn available model ID
messagesMessages containing role and content
streamSet to true for streaming output

Python example

python
import os
from openai import OpenAI

client = OpenAI(api_key=os.environ["YUNHAI_API_KEY"], base_url="http://localhost:3187/v1")
response = client.chat.completions.create(
    model="YOUR_MODEL_ID",
    messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)

Install the SDK with pip install openai. Additional parameters depend on the upstream model.