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
}
]
}

An agent you saved in the console can be called by name from your own code. Send the same request, with "agent:" and the agent’s name as the model:

Terminal window
curl https://api.oraicle.me/v1/chat/completions \
-H "Authorization: Bearer $ORAICLE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "agent:Markets check",
"messages": [{ "role": "user", "content": "How did NVDA close?" }]
}'

The agent answers with its own model, instructions and live data, and your messages are its input. The answer comes in the same shape as any chat completion, whole or streamed with "stream": true. A few things work differently from a plain call:

  • The name is the one in your console. If no agent has exactly that name, one whose name differs only in capital letters is used. Only your own account’s agents can be called.
  • The tools you send are not used: the agent uses the live data you switched on for it.
  • max_tokens is at most 4,000 for each model call, as for a run from the console.
  • Each call is paid from your wallet like a run from the console, counts toward the agent’s daily cap, and is kept in the agent’s runs in the console for 30 days, with your last message and the answer.

When a call can’t run, nothing is charged, and the answer says why:

Status Code What it says
400 invalid_parameter messages: send at least one message, each with a role and content.
402 day_cap This agent has reached today’s spending cap. It runs again after midnight UTC.
403 agent_disabled We stopped this agent. If you think that is a mistake, write to abuse@oraicle.me.
404 agent_not_found No agent on this account has that name.
409 agent_name_ambiguous More than one of your agents has that name. Give each its own name in the console.
409 agents_not_open Agents are not open yet.

An empty wallet, or a key at its spending limit, is refused as for any other call.