Rynler API quickstart
Use the OpenAI Python SDK with your Rynler API key and a model from the current catalogue.
1. Create a workspace and add credits
Create an account and verify your email address: keys belonging to an unverified account are refused. Usage is prepaid, so add credits from the workspace Usage & billing page before your first request. Review the current rates on the pricing page.
2. Create an API key with a spending cap
In the workspace, create an API key, give it a name and set its lifetime spending cap. The key is displayed once, so copy it immediately and store it as RYNLER_API_KEY in your server environment. The key stops authorizing new requests when its cap is reached. Read API authentication for key handling and rotation.
3. Send your first request
Every inference request needs two headers: Authorization: Bearer with your key, and a fresh Idempotency-Key of 16 to 128 letters, digits, hyphens or underscores. A UUID works. With curl:
curl https://api.rynler.com/v1/chat/completions \
-H "Authorization: Bearer $RYNLER_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"model": "xiaomi/mimo-v2.6-flash",
"messages": [{"role": "user", "content": "Hello, world."}],
"max_tokens": 1024
}'Install the openai Python package, set RYNLER_API_KEY in your environment, then send a chat completion:
import os
import uuid
from openai import OpenAI
client = OpenAI(
base_url="https://api.rynler.com/v1",
api_key=os.environ["RYNLER_API_KEY"]
)
response = client.chat.completions.create(
model="xiaomi/mimo-v2.6-flash",
messages=[{"role": "user", "content": "Hello, world."}],
max_tokens=1024,
extra_headers={"Idempotency-Key": str(uuid.uuid4())}
)
print(response.choices[0].message.content)Choose a model ID from the current catalogue. Check service availability if a request cannot be served.
4. Read the usage in the response
A successful response follows the chat completion format: the answer is in choices[0].message.content, the stop cause in finish_reason, and the verified token counts in usage.prompt_tokens, usage.completion_tokens and usage.total_tokens. The request first reserves its maximum possible cost, then settles against these reported tokens. Your workspace lists recent requests with their status and cost.
5. Stream when you need it
Set stream to true to receive server-sent events. The final event carries finish_reason and usage before [DONE]. Which models stream progressively is described in the API reference.
Common first errors
Errors return an error object with a code, a message and a requestId.
401 API_KEY_REQUIRED: theAuthorizationheader is missing or is not a bearer Rynler key.401 API_KEY_INVALID: the key is unknown or revoked, or its account is not verified.403 TERMS_ACCEPTANCE_REQUIRED: accept the current Terms and Conditions in your account.400 INVALID_REQUEST: a missing or malformedIdempotency-Key, or an unsupported field in the body.402 INSUFFICIENT_CREDITS: the available balance cannot cover the reservation. Add credits or lowermax_tokens.429 KEY_QUOTA: the reservation would exceed the key's remaining spending cap.400 TOKEN_LIMIT: the input plusmax_tokensdoes not fit the model.503 MODEL_UNAVAILABLE: the model ID is unknown or not currently available.