SDKs & first request
Clavue exposes an OpenAI-compatible Chat Completions API. Point any OpenAI client at https://api.clavue.com/v1 with a membership API key. Layout below mirrors docs.x.ai developer quickstart steps.
Step 1: Create a Clavue account
Sign up at www.clavue.com/account (email OTP / password / Google where enabled). Free tier includes daily fast + premium quota shared across Chat, imux, CLI, and API.
Step 2: Generate an API key
Open Account → API keys, create a key, then export it:
export CLAVUE_TOKEN="your_api_key"
# OpenAI SDK convention:
export OPENAI_API_KEY="$CLAVUE_TOKEN"
export OPENAI_BASE_URL="https://api.clavue.com/v1"Step 3: Install an SDK
Use the official OpenAI SDKs — no proprietary package required.
# Python
pip install openai
# Node.js
npm install openaiStep 4a: First request (curl)
curl -s https://api.clavue.com/v1/chat/completions \
-H "Authorization: Bearer $CLAVUE_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "clavue-2.1",
"messages": [
{"role": "user", "content": "Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}"}
]
}'Step 4b: Python (OpenAI SDK)
from openai import OpenAI
client = OpenAI(
api_key="YOUR_CLAVUE_TOKEN",
base_url="https://api.clavue.com/v1",
)
r = client.chat.completions.create(
model="clavue-2.1",
messages=[{
"role": "user",
"content": "Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}",
}],
)
print(r.choices[0].message.content)Step 4c: Node.js (OpenAI SDK)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.CLAVUE_TOKEN,
baseURL: "https://api.clavue.com/v1",
});
const r = await client.chat.completions.create({
model: "clavue-2.1",
messages: [{
role: "user",
content: "Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}",
}],
});
console.log(r.choices[0].message.content);Step 5: Streaming
Set stream: true for token-by-token delivery. See the Streaming guide for full examples.
stream = client.chat.completions.create(
model="clavue-2.1-fast",
messages=[{"role": "user", "content": "Write a short haiku about agents."}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content or ""
print(delta, end="", flush=True)Step 6: Image generation (clavue-img)
Official image product id clavue-img via chat completions (Markdown image links in the reply). Prefer web Chat or imux Agent Chat for inline previews.
r = client.chat.completions.create(
model="clavue-img",
messages=[{"role": "user", "content": "A futuristic city skyline at sunset, cinematic"}],
)
print(r.choices[0].message.content)