Chat Completions
POST /v1/chat/completions: the main call, in the OpenAI SDK format.
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
| Field | Type | Notes |
|---|---|---|
model | string, required | Raven Flash or Raven Max, in any letter case. See Models. |
messages | array, required, not empty | Roles system, user, assistant and tool. A user message may hold text and image parts (Vision). |
stream | boolean | true for server-sent events. See Streaming. |
max_tokens, max_completion_tokens | integer | The most tokens the answer may use, reasoning included. Send either; if you send both, the smaller one is used. |
reasoning_effort | string | none, low, medium or high. Leave it out for the default. See Reasoning. |
tools, tool_choice, parallel_tool_calls | array, string or object, boolean | Functions the model may call. See Tool calling. |
response_format | object | Passed to the model as sent. |
temperature, top_p, top_k, stop, seed, frequency_penalty, presence_penalty | number, string or array | Sampling fields, passed to the model as sent. |
logprobs, top_logprobs, user | various | Passed 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
{ "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} }}modelis always the listed name of the model you asked for.usageis what you are billed for.prompt_tokens_details.cached_tokensis 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 yourstopstrings.length: the answer reachedmax_tokens. Raise it, or lowerreasoning_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.
Related
- Streaming
- Tool calling
- Messages format, the same call in the Anthropic SDK format