Skip to content

Chat Completions

Chat Completions is the endpoint everything else hangs off: send a list of messages, get the model’s reply, in the OpenAI request and response shape.

POST/chat/completions
ParameterTypeRequiredDescription
modelstringYesID of the model to use (e.g., “meta-llama/Llama-3.3-70B-Instruct”, “deepseek-ai/DeepSeek-R1-0528”)
messagesarrayYesArray of message objects with role and content
temperaturenumberNoWhat sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic
max_tokensintegerNoMaximum tokens to generate (default varies by model)
toolsarrayNoLive-data oracles the model may call, e.g. [{ “type”: “weather” }] — see Live data (oracles). Standard function tools are accepted too. Each oracle call is billed per successful lookup on top of the tokens.
from openai import OpenAI
# Set your API key and base URL
client = OpenAI(
base_url = "https://api.oraicle.me/v1",
# For production, you should not place your key
# in the code but in the environment variables
api_key = "<your_api_key>",
)
# Make a simple chat completion request
response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-R1-0528",
messages=[
{"role": "system", "content": "You are a smarter assistant."},
{
"role": "user",
"content":
"In two sentences, what is an API key and why should I keep it secret?"
}
]
)
print(response.choices[0].message.content)
{
"id": "chatcmpl-123abc456def",
"object": "chat.completion",
"created": 1677858242,
"model": "deepseek-ai/DeepSeek-R1-0528",
"usage": {
"prompt_tokens": 31,
"completion_tokens": 62,
"total_tokens": 93
},
"choices": [
{
"message": {
"role": "assistant",
"content": "An API key is a secret string that identifies your account when your code calls a service, so each request can be authorised and billed to you. Keep it out of client-side code and version control: anyone who has it can make requests, and spend, as you."
},
"finish_reason": "stop",
"index": 0
}
]
}