Lightweight
API Documentation

Lightweight AI Gateway

One API key, works everywhere. A universal, OpenAI-compatible AI gateway providing access to 40+ frontier and open-source models.

Getting Started

Connecting to Lightweight is incredibly simple. Because our API is 100% compatible with OpenAI's API format, any tool or library that supports OpenAI can connect to Lightweight by changing just two settings.

  1. Obtain your API key from the Lightweight Dashboard.
  2. Set your tool's API base URL to https://api.lightweight.one/v1
  3. Use your Lightweight key in place of an OpenAI key.

For standard shell environments, simply export these variables:

bash
export OPENAI_API_KEY="lw-your-key-here"
export OPENAI_BASE_URL="https://api.lightweight.one/v1"

API Reference

The Lightweight API strictly follows the OpenAI specification, meaning no new SDKs are required. You can interact with it using standard HTTP requests or any OpenAI client library.

  • Base URL: https://api.lightweight.one/v1
  • Authentication: Bearer token via Authorization header using your lw-... key.

Chat Completions

POST /v1/chat/completions

Generate text or code based on conversational context.

bash
curl "https://api.lightweight.one/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer lw-your-key-here" \
  -d '{
    "model": "gpt-5.1-codex",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Write a quicksort in Python."}
    ],
    "stream": true
  }'

Streaming Support: Set "stream": true in your request to receive Server-Sent Events (SSE) exactly matching OpenAI's streaming format.

List Models

GET /v1/models

Returns a list of all currently accessible models on your account.

bash
curl "https://api.lightweight.one/v1/models" \
  -H "Authorization: Bearer lw-your-key-here"

Check Usage

GET /v1/usage

Returns your current token consumption and remaining quota.

Error Codes

Status Description
401 Unauthorized Invalid, revoked, or missing API key.
403 Forbidden Account limit reached, or model access denied.
429 Too Many Requests Rate limit exceeded. Check Retry-After header.
502 Bad Gateway Upstream provider error or timeout.

Models Catalog

We provide unified access to 41 state-of-the-art models. Use the exact string in the "Model ID" column for the model parameter in your API requests.

Frontier Models (22)

Model ID Context Status
gpt-5.3-codex 128K GA
gpt-5.2-codex 128K GA
gpt-5.1-codex 128K GA
gpt-5.1-codex-max 200K+ GA
gpt-5.1-codex-mini 64K Preview
gpt-5.2 128K GA
gpt-5.1 128K GA
gpt-5-mini 128K GA
claude-opus-4.6 200K GA
claude-opus-4.6-fast 200K Preview
claude-opus-4.5 200K GA
claude-sonnet-4.6 200K GA
claude-sonnet-4.5 200K GA
claude-sonnet-4 200K GA
claude-haiku-4.5 200K GA
gemini-3.1-pro 1M+ Preview
gemini-3-pro 1M+ Preview
gemini-3-flash 1M+ Preview
gemini-2.5-pro 1M+ GA
grok-code-fast-1 128K GA
raptor-mini 64K Preview
goldeneye 128K Preview

Open Models (19)

Model ID Context Status
gpt-4o 128K GA
gpt-4o-mini 128K GA
o1 200K GA
o1-mini 128K GA
o3-mini 200K GA
o4-mini 200K GA
Llama-3.3-70B-Instruct 128K GA
Llama-3.2-90B-Vision-Instruct 128K GA
Llama-4-Scout 512K Preview
Phi-4 16K GA
Phi-4-mini-instruct 128K GA
MAI-DS-R1 128K GA
DeepSeek-R1 128K GA
DeepSeek-V3 128K GA
Mistral-Small-3.1 128K GA
Codestral-2501 256K GA
Mistral-Medium-3 128K GA
Command-R-Plus 128K GA
Command-R 128K GA

Integration Guides

Because Lightweight perfectly mimics the OpenAI API, you can seamlessly connect practically any AI coding tool, editor, or framework. Find your tool below.

OpenCode

OpenCode supports generic OpenAI-compatible endpoints directly in its settings.

  1. Open OpenCode Settings.
  2. Find the AI Provider section and select OpenAI-compatible.
  3. Set Base URL to https://api.lightweight.one/v1.
  4. Set API Key to your lw-... key.
  5. Save and test a prompt.

Tip: You can manually type the model name like claude-opus-4.6 if it doesn't appear in a dropdown.

Cursor

Cursor allows overriding the default OpenAI Base URL for custom proxy routing.

  1. Open Cursor Settings.
  2. Navigate to Models > OpenAI.
  3. Toggle "Override OpenAI Base URL".
  4. Set the URL to https://api.lightweight.one/v1.
  5. Paste your lw-... key in the OpenAI API Key field.
  6. Ensure external infrastructure integration toggles are off.

Aider

Aider is an AI pair programming tool in your terminal. You can pass the API settings as CLI arguments or environment variables.

bash
aider --openai-api-key "lw-your-key-here" --openai-api-base "https://api.lightweight.one/v1" --model "claude-sonnet-4.6"

Alternatively, export OPENAI_API_KEY and OPENAI_API_BASE in your shell profile.

Zed

Zed's built-in AI assistant can be configured via your settings.json.

  1. Open Zed and edit your settings.json.
  2. Add or update the language_models block:
json
"language_models": {
  "openai": {
    "api_url": "https://api.lightweight.one/v1",
    "api_key": "lw-your-key-here"
  }
}

Continue

Continue is an open-source IDE extension.

  1. Open your ~/.continue/config.json file.
  2. In the models array, configure an OpenAI provider:
json
{
  "models": [
    {
      "title": "Lightweight Opus",
      "provider": "openai",
      "model": "claude-opus-4.6",
      "apiKey": "lw-your-key-here",
      "apiBase": "https://api.lightweight.one/v1"
    }
  ]
}

Cline

Cline perfectly matches any OpenAI-compatible endpoint.

  1. Open Cline's settings panel.
  2. Under API Provider, select OpenAI Compatible.
  3. Set Base URL to https://api.lightweight.one/v1.
  4. Paste your lw-... key in the API Key field.
  5. Specify the Model ID (e.g., gpt-5.1-codex).

Windsurf

Windsurf can be configured to use external API gateways.

  1. Open Windsurf settings.
  2. Navigate to the API or Models configuration section.
  3. Select Custom API Endpoint.
  4. Enter the Base URL: https://api.lightweight.one/v1.
  5. Input your Lightweight API key.

Ollama

If you use tools that expect an Ollama-style proxy but want to route them through Lightweight, set these environment variables before starting the tool.

bash
export OLLAMA_OPENAI_BASE_URL="https://api.lightweight.one/v1"
export OLLAMA_OPENAI_API_KEY="lw-your-key-here"

OpenAI SDK (Python)

The official Python SDK requires no modifications other than instantiating the client with our base URL and key.

python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.lightweight.one/v1",
    api_key="lw-your-key-here"
)

response = client.chat.completions.create(
    model="gpt-5.1-codex",
    messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)

OpenAI SDK (Node.js)

Similarly, the Node.js/TypeScript SDK natively supports custom base URLs.

typescript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.lightweight.one/v1",
  apiKey: "lw-your-key-here",
});

async function main() {
  const completion = await client.chat.completions.create({
    model: "claude-sonnet-4.6",
    messages: [{ role: "user", content: "Hello!" }],
  });
  console.log(completion.choices[0].message.content);
}
main();

LangChain

Use the standard ChatOpenAI class in LangChain, overriding the base URL parameter.

python
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    base_url="https://api.lightweight.one/v1",
    api_key="lw-your-key-here",
    model="claude-opus-4.6"
)

print(llm.invoke("Explain quantum entanglement.").content)

LiteLLM

When using LiteLLM to proxy requests locally, direct the OpenAI proxy target to Lightweight.

bash
litellm --model openai/claude-opus-4.6 \
  --api_base "https://api.lightweight.one/v1" \
  --api_key "lw-your-key-here"

Any OpenAI-Compatible Tool

For any other application that doesn't have an explicit UI setting, environment variables are universally respected by the underlying OpenAI SDKs.

  1. Find where the tool loads its environment variables (e.g., a .env file, a shell script, or system environment settings).
  2. Set OPENAI_API_KEY=lw-your-key
  3. Set OPENAI_BASE_URL=https://api.lightweight.one/v1
  4. Restart the application.

Rate Limits

To ensure fair usage across the beta, we enforce RPM (Requests Per Minute) limits based on your account tier. When you exceed the limit, you will receive a 429 Too Many Requests response.

Account Tier Requests Per Minute (RPM)
Beta Access 60 RPM
Pro Tier 250 RPM
Enterprise Custom

If you hit a rate limit, the response headers will include a Retry-After value indicating how many seconds you should wait before retrying.

Frequently Asked Questions

What models are available?

We provide unified access to 41 models, including 22 frontier and 19 open-source models. See the complete catalog for exact model IDs.

Is this OpenAI-compatible?

Yes. Lightweight is designed as a drop-in replacement. Any tool, library, or codebase that can talk to OpenAI can talk to Lightweight simply by changing the Base URL and API Key.

How do I check my usage?

You can use the Dashboard UI, or query the GET /v1/usage endpoint programmatically.

What happens when I hit my limit?

You will receive a 403 Forbidden HTTP status code with a clear message indicating your quota has been exhausted.

Can I use streaming?

Yes. Add "stream": true to your /chat/completions payload. Responses will be streamed using Server-Sent Events (SSE) following the exact OpenAI format.

How do I get an invite?

Lightweight is currently in an invite-only beta. Reach out in our Discord or community channels to request access.

Is this open source?

Yes. The gateway implementation is open-source and available at github.com/templarsco/lightweight-api.