Chat Completions
OpenAI-compatible text generation with tool calling and streaming.
The Chat Completions API is fully OpenAI-compatible. If you’re already using the OpenAI SDK or any OpenAI-compatible client, you can point it at Lightcone with minimal changes.
This API is for text generation, chatbots, and general-purpose tool-calling workflows (e.g., calling your own functions like get_weather).
Basic usage
Section titled “Basic usage”from tzafon import Lightcone
client = Lightcone()
result = client.chat.create_completion( model="tzafon.northstar-cua-fast-1.6", messages=[ {"role": "user", "content": "What is the capital of France?"}, ],)print(result)import Lightcone from "@tzafon/lightcone";
const client = new Lightcone();
const result = await client.chat.createCompletion({ model: "tzafon.northstar-cua-fast-1.6", messages: [ { role: "user", content: "What is the capital of France?" }, ],});console.log(result);Streaming
Section titled “Streaming”Set stream: true to receive tokens as they’re generated:
stream = client.chat.create_completion( model="tzafon.northstar-cua-fast-1.6", messages=[ {"role": "user", "content": "Write a haiku about programming"}, ], stream=True,)
for chunk in stream: delta = chunk.choices[0].delta if delta.content: print(delta.content, end="", flush=True)const stream = await client.chat.createCompletion({ model: "tzafon.northstar-cua-fast-1.6", messages: [ { role: "user", content: "Write a haiku about programming" }, ], stream: true,});
for await (const chunk of stream) { const delta = chunk.choices[0]?.delta; if (delta?.content) process.stdout.write(delta.content);}Tool calling
Section titled “Tool calling”Define functions the model can call:
result = client.chat.create_completion( model="tzafon.northstar-cua-fast-1.6", messages=[ {"role": "user", "content": "What's the weather in San Francisco?"}, ], tools=[ { "type": "function", "function": { "name": "get_weather", "description": "Get the current weather for a location", "parameters": { "type": "object", "properties": { "location": {"type": "string", "description": "City name"}, }, "required": ["location"], }, }, }, ],)const result = await client.chat.createCompletion({ model: "tzafon.northstar-cua-fast-1.6", messages: [ { role: "user", content: "What's the weather in San Francisco?" }, ], tools: [ { type: "function", function: { name: "get_weather", description: "Get the current weather for a location", parameters: { type: "object", properties: { location: { type: "string", description: "City name" }, }, required: ["location"], }, }, }, ],});Available models
Section titled “Available models”| Model | Purpose | Input | Output |
|---|---|---|---|
tzafon.northstar-cua-fast-1.6 | Our latest computer-use model. Recommended; pin this version in production. | $0.50/M tokens | $1.50/M tokens |
tzafon.northstar-cua-fast | Unversioned alias of the previous generation. Prefer the pinned -1.6. | $0.50/M tokens | $1.50/M tokens |
tzafon.sm-1 | Text model specialized for low-level systems programming. | $0.20/M tokens | $0.30/M tokens |
List the models available to your key at any time with client.models.list().
List models programmatically:
models = client.models.list()print(models)const models = await client.models.list();console.log(models);Key parameters
Section titled “Key parameters”| Parameter | Description |
|---|---|
model | Model to use |
messages | Conversation history |
temperature | Randomness (0 = deterministic, higher = more creative) |
max_completion_tokens | Maximum tokens to generate |
stream | Enable streaming responses |
tools | Function definitions for tool calling |
tool_choice | "auto", "none", or "required" |
response_format | Force "json_object" or JSON schema output |
Using with OpenAI SDK
Section titled “Using with OpenAI SDK”Since the API is OpenAI-compatible, you can use the OpenAI SDK directly:
from openai import OpenAI
client = OpenAI( api_key="sk_your_tzafon_key", base_url="https://api.tzafon.ai/v1",)
response = client.chat.completions.create( model="tzafon.northstar-cua-fast-1.6", messages=[{"role": "user", "content": "Hello!"}],)import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk_your_tzafon_key", baseURL: "https://api.tzafon.ai/v1",});
const response = await client.chat.completions.create({ model: "tzafon.northstar-cua-fast-1.6", messages: [{ role: "user", content: "Hello!" }],});Using with the Anthropic SDK
Section titled “Using with the Anthropic SDK”Lightcone also speaks the Anthropic Messages dialect at /v1/messages (including count_tokens). If your stack is built on the Anthropic SDK, point it at Lightcone the same way:
import anthropic
client = anthropic.Anthropic( api_key="sk_your_tzafon_key", base_url="https://api.tzafon.ai",)
response = client.messages.create( model="tzafon.northstar-cua-fast-1.6", max_tokens=1024, messages=[{"role": "user", "content": "Hello!"}],)import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({ apiKey: "sk_your_tzafon_key", baseURL: "https://api.tzafon.ai",});
const response = await client.messages.create({ model: "tzafon.northstar-cua-fast-1.6", max_tokens: 1024, messages: [{ role: "user", content: "Hello!" }],});See also
Section titled “See also”- Responses API: computer-use agent interface (also OpenAI-compatible)
- Tasks: AI-powered automation for computer tasks
- How Lightcone works: how Chat Completions fits into the platform