Python (OpenAI SDK)
from openai import OpenAI
client = OpenAI(
api_key="tr_live_...",
base_url="https://api.trelis.com/v1",
)
stream = client.chat.completions.create(
model="gemma-4-e4b-conversational",
stream=True,
stream_options={"include_usage": True},
messages=[
{"role": "system", "content": "You answer repair calls for a bike shop. Keep replies brief and spoken."},
{"role": "user", "content": "Is my repair ready? Ticket B42."},
],
tools=[
{
"type": "function",
"function": {
"name": "lookup_repair",
"description": "Look up the status of a repair ticket.",
"parameters": {
"type": "object",
"properties": {"ticket": {"type": "string"}},
"required": ["ticket"],
},
},
}
],
tool_choice="auto",
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta:
print(chunk.choices[0].delta)
curl (streaming SSE with tool calling)
curl -sN https://api.trelis.com/v1/chat/completions \
-H "Authorization: Bearer $TRELIS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemma-4-e4b-conversational",
"stream": true,
"stream_options": {"include_usage": true},
"messages": [
{"role": "system", "content": "You answer repair calls for a bike shop. Keep replies brief and spoken."},
{"role": "user", "content": "Is my repair ready? Ticket B42."}
],
"tools": [
{
"type": "function",
"function": {
"name": "lookup_repair",
"description": "Look up the status of a repair ticket.",
"parameters": {
"type": "object",
"properties": {"ticket": {"type": "string"}},
"required": ["ticket"]
}
}
}
],
"tool_choice": "auto"
}'