How do I send a system prompt from Python?
Put your instructions in a system message first. The Model API also accepts the developer role.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.gateway.clatterlabs.xyz/v1",
api_key=os.environ["CLATTER_API_KEY"],
default_headers={"X-Clatter-Account": os.environ["CLATTER_ACCOUNT_ID"]},
)
resp = client.chat.completions.create(
model="supercosmos-flash",
messages=[
{"role": "system", "content": "You are a concise assistant for a bike shop. Answer in two sentences."},
{"role": "user", "content": "How often should I oil my chain?"},
],
)
print(resp.choices[0].message.content)
Every request also includes a short Clatter Labs instruction block, which counts toward input tokens. Your system prompt is added on top of it.
The client setup above (base URL, key and the X-Clatter-Account header) is the same in every Python example; see Set up the Python SDK. Full parameter list: Create a chat completion.
Good to know#
- If calls fail unexpectedly, check status.clatterlabs.com before debugging further.
- New accounts get $5 of free credit; top up from $1 to $800 per purchase in Console › Billing › Credits. Billing
- Your key's account is responsible for your end users' text under the Abuse policy. What it means for apps
Still need help?#
- General support: support@clatterlabs.com or team@clatterlabs.xyz
- Infrastructure questions, or permanent deletion of your data (your whole account or one service): infrastructure@clatterlabs.xyz
We usually reply within the first hour, and always within 24 hours. A full support team is with you.
Related articles
- How do I set up the OpenAI Python SDK for the Model API?
- How do I use tool calling in Python?
- How do I read Max or Heavy's reasoning in Python?
- Which message roles can I use?
- How do I write a good system prompt in the Playground?Console
- How should I write a system prompt for SuperCosmos?SuperCosmos models
Still need help?
Tried the steps above and still stuck? Email us. We usually reply within the first hour, and always within 24 hours. A full support team is with you.
Infrastructure questions, or permanent deletion of your data
infrastructure@clatterlabs.xyzFor deleting your whole account or the data of one service.