How to Use Chirp-01

A guide to using Chirp-01 with OpenAI-compatible API endpoints

1. Setup

Use your API key from the dashboard to authenticate requests to the Chirp-01 endpoint.

Endpoint: https://api.ozone-ai.com/v1/chat/completions

Add your API key to the Authorization header:

Authorization: Bearer YOUR_API_KEY

Replace YOUR_API_KEY with the key from your API Keys dashboard.

2. Basic Usage

Send a POST request to the chat completions endpoint with your messages.

Example Request (Python)

import requests

api_key = "YOUR_API_KEY"
url = "https://ozone-ai.com/api/v1/chat/completions"

headers = {
    "Authorization": f"Bearer {api_key}",
    "Content-Type": "application/json"
}

data = {
    "model": "chirp-01",
    "messages": [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Summarize the benefits of edge computing"}
    ],
    "max_tokens": 50
}

response = requests.post(url, json=data, headers=headers)
print(response.json())

Example Response

{
    "id": "chatcmpl-xyz",
    "object": "chat.completion",
    "created": 1699999999,
    "model": "chirp-01",
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "Edge computing reduces latency, saves bandwidth, and enhances privacy."
            },
            "finish_reason": "length"
        }
    ],
    "usage": {
        "prompt_tokens": 20,
        "completion_tokens": 15,
        "total_tokens": 35
    }
}

3. Streaming Responses

Enable streaming to receive responses in real-time by setting "stream": true.

Example Request (JavaScript)

const apiKey = 'YOUR_API_KEY';
const url = 'https://ozone-ai.com/api/v1/chat/completions';

const response = await fetch(url, {
    method: 'POST',
    headers: {
        'Authorization': `Bearer ${apiKey}`,
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
        model: 'chirp-01',
        messages: [
            { role: 'system', content: 'You are a helpful assistant.' },
            { role: 'user', content: 'Summarize the benefits of edge computing' }
        ],
        stream: true,
        max_tokens: 50
    })
});

const reader = response.body.getReader();
const decoder = new TextDecoder();

while (true) {
    const { value, done } = await reader.read();
    if (done) break;
    const chunk = decoder.decode(value);
    const lines = chunk.split('\n').filter(line => line.trim());
    for (const line of lines) {
        if (line.startsWith('data: ')) {
            const data = line.slice(6);
            if (data === '[DONE]') break;
            const json = JSON.parse(data);
            const content = json.choices[0].delta.content || '';
            if (content) console.log(content);
        }
    }
}

This streams the response chunk-by-chunk, ideal for real-time applications.