hu ▾
Try with trial credit

Lama API Documentation: Quickstart Guide

Get started with the uncensored LLM API in minutes. This quickstart guide covers authentication, standard requests, streaming, and key limits using the OpenAI-compatible format.

Base URL and Authentication

The lama API base URL is HTTPS://api.lamaapi.com/v1. You authenticate by sending your API key in the Authorization header as a Bearer token. Create an account via Google or email to receive your key instantly. Use this key with any standard OpenAI SDK or HTTP client.

curl https://api.lamaapi.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "List the top five features of the new release"}]
  }'

Standard Chat Completions Endpoint

Send messages to the single uncensored model using the /v1/chat/completions endpoint. Specify the model ID as uncensored to ensure consistent behavior without routing variability. The API returns text responses based on your system and user prompts.

from openai import OpenAI

client = OpenAI(base_url="https://api.lamaapi.com/v1", api_key="YOUR_KEY")

resp = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Summarise this thread without softening it."}],
)
print(resp.choices[0].message.content)

Streaming Responses with Server-Sent Events

Enable streaming by setting stream: true in your request. The API returns Server-Sent Events (SSE) containing partial text chunks. This reduces perceived latency for long outputs, allowing you to render tokens as they are generated without waiting for the full completion.

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.lamaapi.com/v1", apiKey: process.env.API_KEY });

const resp = await client.chat.completions.create({
  model: "uncensored",
  messages: [{ role: "user", content: "Draft a villain monologue for my game." }],
});
console.log(resp.choices[0].message.content);

Function Calling and Tool Use

Define tools in your request body to enable function calling. The model can generate structured arguments for your predefined functions. Use the tool_choice parameter to force specific behavior or allow the model to decide. This works seamlessly with the uncensored model for complex task automation.

JSON Mode for Structured Outputs

Set response_format to {"type": "json_object"} to force JSON output. This is ideal for parsing data into your application without extra processing. The model adheres to the schema implied by your prompt, ensuring consistent structured responses for your backend systems.

Model Parameters: Temperature, Top P, and Seed

Control creativity with temperature and top_p. Use seed for deterministic outputs during testing. These parameters allow fine-tuning of the uncensored model's behavior. Adjust them based on whether you need precise code generation or more varied creative writing.

Streaming

stream = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Tell the story in second person."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

Frequently asked questions

What is the context window size?

The context window is 100,000 tokens, combining prompt and completion. You can request up to 16,000 tokens per output. If you do not set <code>max_tokens</code>, the limit defaults to 2,048 tokens.

What do HTTP 401, 402, and 429 errors mean?

A 401 error indicates an invalid or missing API key. A 402 error means your prepaid credit is exhausted. A 429 error signals you have exceeded the rate limit of 300 requests per minute.

Is the lama API key unique per account?

Yes, each account has one active key. Generating a new key replaces the previous one immediately. You can create a new key from your dashboard if needed.

Get your API key in seconds

Sign up, copy the key, update the base URL. Simple as that.

Try with trial credit