Chat Completions

POST /v1/chat/completions: the main call, in the OpenAI SDK format.

On this page

POST https://api.dipoleml.com/v1/chat/completions takes a list of messages and returns the model's answer. It uses the OpenAI SDK format, so an OpenAI client works once you change its base URL, its key and the model name.

Make a request

curl

curl https://api.dipoleml.com/v1/chat/completions \  -H "Authorization: Bearer $RAVEN_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "model": "Raven Max",    "messages": [      {"role": "system", "content": "You are a concise technical editor."},      {"role": "user", "content": "Tighten this paragraph: ..."}    ],    "max_tokens": 1000  }'

python

import osfrom openai import OpenAIclient = OpenAI(    base_url="https://api.dipoleml.com/v1",    api_key=os.environ["RAVEN_API_KEY"],)resp = client.chat.completions.create(    model="Raven Max",    messages=[        {"role": "system", "content": "You are a concise technical editor."},        {"role": "user", "content": "Tighten this paragraph: ..."},    ],    max_tokens=1000,)print(resp.choices[0].message.content)

The API keeps no conversation. Send the whole history you want the model to see on every call.

Request fields

FieldTypeNotes
modelstring, requiredRaven Flash or Raven Max, in any letter case. See Models.
messagesarray, required, not emptyRoles system, user, assistant and tool. A user message may hold text and image parts (Vision).
streambooleantrue for server-sent events. See Streaming.
max_tokens, max_completion_tokensintegerThe most tokens the answer may use, reasoning included. Send either; if you send both, the smaller one is used.
reasoning_effortstringnone, low, medium or high. Leave it out for the default. See Reasoning.
tools, tool_choice, parallel_tool_callsarray, string or object, booleanFunctions the model may call. See Tool calling.
response_formatobjectPassed to the model as sent.
temperature, top_p, top_k, stop, seed, frequency_penalty, presence_penaltynumber, string or arraySampling fields, passed to the model as sent.
logprobs, top_logprobs, uservariousPassed to the model as sent.

A field the API does not take is dropped without an error, so check the spelling of every field you rely on. n is one of them: every answer has one choice.

The answer

response (shape)
{  "id": "<completion id>",  "object": "chat.completion",  "created": 1794000000,  "model": "Raven Max",  "system_fingerprint": null,  "choices": [{    "index": 0,    "message": {"role": "assistant", "content": "..."},    "finish_reason": "stop"  }],  "usage": {    "prompt_tokens": 412,    "completion_tokens": 96,    "total_tokens": 508,    "prompt_tokens_details": {"cached_tokens": 0}  }}
  • model is always the listed name of the model you asked for.
  • usage is what you are billed for. prompt_tokens_details.cached_tokens is the part of the input billed at the cached rate (API Credits).
  • The message may also carry the model's reasoning (Reasoning) or tool_calls (Tool calling).

finish_reason

  • stop: the model finished, or reached one of your stop strings.
  • length: the answer reached max_tokens. Raise it, or lower reasoning_effort.
  • tool_calls: the model wants you to run one or more of your tools.
  • content_filter: the answer was stopped by a content filter.

The request id

Every answer the model produced carries an x-request-id header, and so does a 503 that says the service is busy. Quote it when you write to support. The Activity page of your dashboard lists each request with its tokens and cost.

Errors

A refused request answers with an HTTP status and an error object; nothing is billed. Errors and limits lists every code.