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.
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.