Quickstart
From an empty terminal to a streamed Raven answer in about five minutes.
On this page
This guide takes you from no account to a streamed answer from Raven Flash. You need a terminal with curl, or Python with the SDK you already use.
1. Create an API key
- Sign in to your dashboard with Apple, Google or your email address. A new address gets a new account.
- Open API keys and choose Create API key.
- Give it a name that says where it runs. A spending cap and an expiry are optional (Authentication).
- Choose Create key, then Copy key. The key starts with
dcode_sk_.
Keep the key in an environment variable, not in your code:
export RAVEN_API_KEY="dcode_sk_..."2. Add API credits
API calls are paid from prepaid credits, separate from every plan. Open Billing on your dashboard and add a pack of $5, $10, $20 or $50. Credits never expire. With a balance of zero, a call is refused with 402 and insufficient_credits; see API Credits.
3. Make your first request
In the OpenAI SDK format, call POST /v1/chat/completions. The model name is Raven Flash or Raven Max, with the space (Models).
curl
curl https://api.dipoleml.com/v1/chat/completions \ -H "Authorization: Bearer $RAVEN_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "Raven Flash", "messages": [{"role": "user", "content": "Say hello in five words"}] }'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 Flash", messages=[{"role": "user", "content": "Say hello in five words"}],)print(resp.choices[0].message.content)The answer is in choices[0].message.content, and what you are billed for is in usage:
{ "id": "<completion id>", "object": "chat.completion", "created": 1794000000, "model": "Raven Flash", "choices": [{ "index": 0, "message": {"role": "assistant", "content": "..."}, "finish_reason": "stop" }], "usage": { "prompt_tokens": 412, "completion_tokens": 12, "total_tokens": 424, "prompt_tokens_details": {"cached_tokens": 0} }}Every field is explained on Chat Completions. A 401 means the key is missing or wrong (key errors).
4. Stream the answer
Add "stream": true and the answer arrives as server-sent events while the model writes it:
curl
curl -N https://api.dipoleml.com/v1/chat/completions \ -H "Authorization: Bearer $RAVEN_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "Raven Flash", "stream": true, "messages": [{"role": "user", "content": "Explain caching in three sentences"}] }'python
import osfrom openai import OpenAIclient = OpenAI( base_url="https://api.dipoleml.com/v1", api_key=os.environ["RAVEN_API_KEY"],)stream = client.chat.completions.create( model="Raven Flash", stream=True, messages=[{"role": "user", "content": "Explain caching in three sentences"}],)for chunk in stream: if chunk.choices and chunk.choices[0].delta.content: print(chunk.choices[0].delta.content, end="", flush=True)The last chunk carries usage and has no choices, so the Python sample checks for them. The format is on Streaming.
5. Or use the Anthropic SDK format
The same key and models work at POST /v1/messages. Here the SDK's base URL has no /v1, and the key goes in x-api-key:
curl
curl https://api.dipoleml.com/v1/messages \ -H "x-api-key: $RAVEN_API_KEY" \ -H "anthropic-version: 2023-06-01" \ -H "Content-Type: application/json" \ -d '{ "model": "Raven Flash", "max_tokens": 1024, "messages": [{"role": "user", "content": "Say hello in five words"}] }'python
import osfrom anthropic import Anthropicclient = Anthropic( base_url="https://api.dipoleml.com", api_key=os.environ["RAVEN_API_KEY"],)message = client.messages.create( model="Raven Flash", max_tokens=1024, messages=[{"role": "user", "content": "Say hello in five words"}],)print(message.content[0].text)Fields, thinking and streaming in this format are on Messages format.
Next steps
- Models: the two models, their limits and prices.
- Messages format: the Anthropic SDK format in full.
- Use with coding tools: settings for coding agents and editors.
- Errors and limits: every status and code.