Skip to main content
New

Overview

Tzafon provides an OpenAI-compatible chat completions API. You can use the standard OpenAI SDK with Tzafon’s models by simply changing the base URL.
Use your Tzafon API key (TZAFON_API_KEY) with the OpenAI SDK—no separate authentication required.

Quick Start

from openai import OpenAI

client = OpenAI(
    api_key="sk_your_tzafon_api_key",
    base_url="https://api.tzafon.ai/v1"
)

response = client.chat.completions.create(
    model="tzafon.sm-1",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Hello!"}
    ]
)

print(response.choices[0].message.content)

Available Models

ModelDescriptionBest For
tzafon.sm-1Small, fast modelGeneral tasks, quick responses
tzafon.northstar.cua.sftComputer-use optimizedBrowser/desktop automation agents
Use GET /v1/models to retrieve the current list of available models.

Endpoints

Chat Completions

POST https://api.tzafon.ai/v1/chat/completions
Create a chat completion with conversation history. Request Body:
ParameterTypeRequiredDescription
modelstringYesModel ID (e.g., tzafon.sm-1)
messagesarrayYesConversation messages
temperaturenumberNoSampling temperature (0-2). Default: 1
max_tokensnumberNoMaximum tokens to generate
streambooleanNoEnable streaming responses
stoparrayNoStop sequences
Message Format:
{
  "role": "system" | "user" | "assistant",
  "content": "Message text"
}

Streaming

Enable real-time token streaming for responsive UIs:
from openai import OpenAI

client = OpenAI(
    api_key="sk_your_tzafon_api_key",
    base_url="https://api.tzafon.ai/v1"
)

stream = client.chat.completions.create(
    model="tzafon.sm-1",
    messages=[{"role": "user", "content": "Write a short poem"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

List Models

GET https://api.tzafon.ai/v1/models
Returns the list of available models.
from openai import OpenAI

client = OpenAI(
    api_key="sk_your_tzafon_api_key",
    base_url="https://api.tzafon.ai/v1"
)

models = client.models.list()
for model in models.data:
    print(model.id)

Completions (Legacy)

POST https://api.tzafon.ai/v1/completions
For text completion without chat format. Parameters are similar to chat completions, but uses a prompt string instead of messages.

Embeddings

POST https://api.tzafon.ai/v1/embeddings
Generate vector embeddings for text.

Configuration Options

Temperature Presets

PresetTemperatureMax TokensUse Case
Creative1.02048Creative writing, brainstorming
Balanced0.71024General tasks
Precise0.3512Factual responses, code

Example with Options

response = client.chat.completions.create(
    model="tzafon.sm-1",
    messages=[{"role": "user", "content": "Explain quantum computing"}],
    temperature=0.7,
    max_tokens=1024,
    stop=["<|im_end|>", "<|end_of_text|>"]
)

Error Handling

The API returns standard HTTP status codes:
StatusDescription
200Success
400Bad request (invalid parameters)
401Unauthorized (invalid API key)
429Rate limit exceeded
500+Server error
from openai import OpenAI, APIError, RateLimitError, AuthenticationError

client = OpenAI(
    api_key="sk_your_tzafon_api_key",
    base_url="https://api.tzafon.ai/v1"
)

try:
    response = client.chat.completions.create(
        model="tzafon.sm-1",
        messages=[{"role": "user", "content": "Hello"}]
    )
except AuthenticationError:
    print("Invalid API key")
except RateLimitError:
    print("Rate limit exceeded - retry later")
except APIError as e:
    print(f"API error: {e}")

Pricing

LLM API usage is billed per million tokens:
ModelInput TokensOutput Tokens
tzafon.sm-1$0.20 / 1M tokens$0.30 / 1M tokens
tzafon.northstar.cua.sft$0.30 / 1M tokens$1.00 / 1M tokens
Token usage is tracked automatically. View your usage in the developer dashboard.

Using with Computer Automation

Combine the LLM API with browser automation for AI-powered workflows:
from openai import OpenAI
from tzafon import Computer

# LLM client
llm = OpenAI(
    api_key="sk_your_tzafon_api_key",
    base_url="https://api.tzafon.ai/v1"
)

# Computer client
computer_client = Computer()

with computer_client.create(kind="browser") as computer:
    computer.navigate("https://example.com")
    screenshot = computer.screenshot()

    # Use LLM to analyze the page
    response = llm.chat.completions.create(
        model="tzafon.northstar.cua.sft",
        messages=[
            {"role": "system", "content": "You are a web automation assistant."},
            {"role": "user", "content": f"I'm on a webpage. What should I click next? Screenshot: {screenshot}"}
        ]
    )

    print(response.choices[0].message.content)

Next Steps