Search Documentation

Search for pages and headings in the documentation

Quickstart

Get up and running with Liutong in minutes. This guide walks you through making your first API call.

Prerequisites

  • A Liutong API key (starts with lt_). See Getting Access if you don’t have one yet.
  • Python 3.8+, Node.js 18+, or any HTTP client.

1. Install an OpenAI SDK

Liutong is fully compatible with the OpenAI SDK. Install it in your language of choice:

# Python
pip install openai

# Node.js
npm install openai

2. Configure the client

Point the SDK at Liutong’s API endpoint and use your lt_ API key:

from openai import OpenAI

client = OpenAI(
    base_url="https://api.liutong.llby.org/v1",
    api_key="lt_your_api_key",
)
import OpenAI from "openai";

const client = new OpenAI({
    baseURL: "https://api.liutong.llby.org/v1",
    apiKey: "lt_your_api_key",
});

3. Make your first request

response = client.chat.completions.create(
    model="crimson-falcon-4",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is the capital of France?"},
    ],
)

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

4. Try streaming

stream = client.chat.completions.create(
    model="crimson-falcon-4",
    messages=[{"role": "user", "content": "Write a haiku about Rust."}],
    stream=True,
)

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

Next steps