DEVELOPER REFERENCE

LOPI API Documentation

High-speed OpenAI-compatible and Anthropic-compatible AI endpoints

API Base URL
https://lopi.my.id
Why 660s–900s Timeouts Matter: Reasoning models like deepseek-r1:8b run CPU-isolated local inference. Always enable stream=true and configure client/proxy timeouts >= 600s.

Supported Endpoints

GET/v1/modelsList Active Models (/v1/models)
POST/v1/chat/completionsOpenAI Compatible (/v1/chat/completions)
POST/v1/completionsLegacy OpenAI Completions
POST/v1/messagesAnthropic Messages API (/v1/messages)

Authentication

Send your API key via Authorization: Bearer sk-lopi-... or x-api-key: sk-lopi-...

Authorization: Bearer sk-lopi-demo
x-api-key: sk-lopi-demo

Streaming & Timeout Guidance

All AI endpoints support instant non-streaming JSON responses and real-time SSE token streaming.

stream: true 600s–900s Keepalive SSE Chunked

Available Models

Model ID Provider Context Window Input / Output (per 1M) Streaming
glm-5.3 LOPI Frontier AI Engine 131,072 $0.20 / $0.60 Supported
deepseek-v4-pro LOPI Frontier AI Engine 131,072 $0.25 / $0.75 Supported
deepseek-v4.1-flash LOPI Frontier AI Engine 131,072 $0.10 / $0.30 Supported
qwen2.5-coder:1.5b LOPI Core AI Engine 32,768 $0.05 / $0.15 Supported
deepseek-r1:1.5b LOPI Core AI Engine 32,768 $0.08 / $0.24 Supported
gpt-4o-mini LOPI OpenAI Engine 128,000 $0.15 / $0.60 Supported
claude-3-5-haiku-latest LOPI Anthropic Engine 200,000 $0.80 / $4.00 Supported
qwen2.5-coder:7b LOPI Core AI Engine 32,768 $0.10 / $0.30 Supported
deepseek-r1:8b LOPI Core AI Engine 32,768 $0.15 / $0.45 Supported

Normalized Error Codes

HTTP Status Error Code Meaning & Retry Guidance
400VALIDATION_ERRORInput validation failed.
401INVALID_API_KEYAuthentication is required.
402INSUFFICIENT_CREDITSInsufficient available credits.
403RBAC_FORBIDDENYou do not have permission to perform this action.
404NOT_FOUNDRequested resource was not found.
429RATE_LIMIT_EXCEEDEDToo many requests. Please try again later.
503SERVICE_UNAVAILABLENo healthy provider is available for the requested model.
INSTANT INTEGRATION

Code Examples (curl, Python, JavaScript)

cURL — OpenAI & Anthropic Streaming
curl -N https://lopi.my.id/v1/chat/completions \
  -H "Authorization: Bearer sk-lopi-demo" \
  -H "Content-Type: application/json" \
  -d '{"model":"glm-5.3","stream":true,"messages":[{"role":"user","content":"Hello"}]}'

curl -N https://lopi.my.id/v1/messages \
  -H "x-api-key: sk-lopi-demo" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"model":"deepseek-v4-pro","max_tokens":512,"stream":true,"messages":[{"role":"user","content":"Hello"}]}'
Python (openai & anthropic SDKs)
import os
import openai
import anthropic

oai = openai.OpenAI(api_key=os.environ["LOPI_API_KEY"], base_url="https://lopi.my.id/v1", timeout=660.0)
resp = oai.chat.completions.create(model="glm-5.3", messages=[{"role": "user", "content": "Hello"}], stream=True)

ant = anthropic.Anthropic(api_key=os.environ["LOPI_API_KEY"], base_url="https://lopi.my.id", timeout=660.0)
msg = ant.messages.create(model="deepseek-v4-pro", max_tokens=256, messages=[{"role": "user", "content": "Hello"}])
Node.js / TypeScript
import OpenAI from "openai";
import Anthropic from "@anthropic-ai/sdk";

const openai = new OpenAI({ apiKey: process.env.LOPI_API_KEY, baseURL: "https://lopi.my.id/v1", timeout: 660000 });
const anthropic = new Anthropic({ apiKey: process.env.LOPI_API_KEY, baseURL: "https://lopi.my.id", timeout: 660000 });