OpenAI and Anthropic compatible

Connect to the LocAI API

Use your LocAI API key with familiar SDKs. Point your client to the LocAI base URL, select LocAI-Go, and start building.

Create an account Open API keys

Quick Start

Create a key in the dashboard and make your first production request in a few minutes.

01

Create an account

Register with your invitation and sign in to the LocAI dashboard.

02

Generate a key

Create an API key and copy it immediately. The full key is displayed once.

03

Set the base URL

Use https://api.locai.com.au/v1 for OpenAI-compatible SDKs.

04

Call LocAI-Go

Use the exact, case-sensitive model name LocAI-Go in executable requests.

LocAI Models

A focused model family for general intelligence, advanced work, conversation, and retrieval.

LocAI-Go

General Intelligence

Coding, reasoning, chat, tool use, managed search, and multimodal workflows.

LocAI-Pro

Professional Intelligence

The same flagship backend and price as Go today, with a separate identifier for professional workflows.

LocAI-Flash

Fast Text Intelligence

Muse Glimmer 30B for text and tools. 128K context, no image input. A$0.50 input / A$3.00 output per million tokens, half Go's price.

LocAI-Talk

Language and Conversation

Natural dialogue, multilingual communication, assistants, and content workflows.

LocAI-Reader

Retrieval Intelligence

Embedding, semantic retrieval, document understanding, and reranking workflows.

The runnable examples below use LocAI-Go. Model identifiers are case-sensitive; use the exact spelling returned by GET /v1/models in application code.

OpenAI-Compatible Setup

Install the official OpenAI SDK and change the base URL. No LocAI-specific client library is required.

Python
from openai import OpenAI

client = OpenAI(
    api_key="LCCM_<your_key>",
    base_url="https://api.locai.com.au/v1",
)

response = client.chat.completions.create(
    model="LocAI-Go",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Explain this repository structure."},
    ],
)

print(response.choices[0].message.content)
JavaScript / TypeScript
import OpenAI from "openai";

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

const response = await client.chat.completions.create({
  model: "LocAI-Go",
  messages: [{ role: "user", content: "Write a TypeScript health check." }],
});

console.log(response.choices[0].message.content);
cURL / Raw HTTP
curl -X POST "https://api.locai.com.au/v1/chat/completions" \
  -H "Authorization: Bearer LCCM_<your_key>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "LocAI-Go",
    "messages": [{"role": "user", "content": "Hello, LocAI!"}],
    "max_tokens": 300
  }'
Streaming in Python
stream = client.chat.completions.create(
    model="LocAI-Go",
    messages=[{"role": "user", "content": "Create a deployment checklist."}],
    stream=True,
)

for event in stream:
    text = event.choices[0].delta.content
    if text:
        print(text, end="", flush=True)

Anthropic-Compatible Setup

Existing Anthropic SDK applications can use LocAI by setting the Anthropic-compatible base URL.

Anthropic Python SDK
from anthropic import Anthropic

client = Anthropic(
    api_key="LCCM_<your_key>",
    base_url="https://api.locai.com.au/anthropic",
)

message = client.messages.create(
    model="LocAI-Go",
    max_tokens=300,
    messages=[{"role": "user", "content": "Hello, LocAI!"}],
)

print(message.content[0].text)

Authentication and URLs

Keep API keys on the server. Never embed a secret key in browser JavaScript, public repositories, screenshots, or support messages.

Bearer authentication

Authorization: Bearer LCCM_<your_key>

Create and revoke keys under Dashboard → API Keys. Store the key in an environment variable such as LOCAI_API_KEY.

Base URL versus full path

SDK configuration uses https://api.locai.com.au/v1 or https://api.locai.com.au/anthropic. Raw HTTP clients use the complete endpoint path. Do not append /chat/completions to an SDK base URL.

API Reference

These are the implemented public inference routes. Every route requires a valid LocAI API key.

OpenAI compatible
POST
/v1/chat/completions
Chat, streaming, tool calling, and multimodal input
GET
/v1/models
List model identifiers available to your key
Anthropic compatible
POST
/anthropic/v1/messages
Messages, streaming events, tools, and multimodal input
GET
/anthropic/v1/models
List models in Anthropic-compatible format

Multimodal Input

LocAI-Go accepts image content through both compatibility protocols. Use a reachable HTTPS image URL or a supported data URL.

OpenAI image input
response = client.chat.completions.create(
    model="LocAI-Go",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "Describe this image."},
            {"type": "image_url", "image_url": {
                "url": "https://example.com/image.png"
            }},
        ],
    }],
)

Managed Web Search

Ask the Gateway to perform bounded web search for current or verifiable questions. Managed search is opt-in per request.

Request headers

X-LocAI-Agent: managed
X-LocAI-Web-Search: auto

Search modes

offDo not use Gateway-managed search.
autoSearch when the request needs current or verifiable information.
requiredAttempt one bounded search before answering.

Troubleshooting

Most integration problems come from an incorrect base URL, a missing Bearer token, or a model-name typo.

400Invalid request or modelUse the exact LocAI-Go identifier and a valid messages array.
401Authentication failedSend the key as Authorization: Bearer <key> and verify it has not been revoked.
402Insufficient balanceAdd wallet credit in Billing before retrying the request.
403Key or account access blockedCheck API-key status, account status, and model restrictions.
429Rate limit reachedRetry with exponential backoff and reduce concurrent requests.

Ready to make your first request?

Create an API key, keep it server-side, and start with the LocAI-Go examples above.

Manage API keys