Lightweight
API Documentation

Lightweight AI Gateway

One API key, works everywhere. A universal, OpenAI-compatible AI gateway providing access to 40 frontier and open & specialized 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",
    "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 40 state-of-the-art models. Use the exact string in the "Model ID" column for the model parameter in your API requests.

Frontier Models (16)

Model ID Context Status
gpt-5128KGA
gpt-5-chat128KGA
gpt-5-mini128KGA
gpt-5-nano128KGA
gpt-4.11MGA
gpt-4.1-mini1MGA
gpt-4.1-nano1MGA
gpt-4o128KGA
gpt-4o-mini128KGA
o3200KGA
o3-mini200KGA
o4-mini200KGA
o1200KGA
o1-mini128KGA
grok-3131KGA
grok-3-mini131KGA

Open & Specialized Models (24)

Model ID Context Status
llama-4-maverick-17b-128e-instruct-fp8256KGA
llama-4-scout-17b-16e-instruct512KGA
meta-llama-3.1-405b-instruct128KGA
meta-llama-3.1-8b-instruct128KGA
llama-3.3-70b-instruct128KGA
llama-3.2-11b-vision-instruct128KGA
llama-3.2-90b-vision-instruct128KGA
phi-416KGA
phi-4-mini-instruct128KGA
phi-4-mini-reasoning128KGA
phi-4-multimodal-instruct128KGA
phi-4-reasoning16KGA
mai-ds-r132KGA
codestral-2501256KGA
ministral-3b128KGA
mistral-medium-2505128KGA
mistral-small-250332KGA
deepseek-r1164KGA
deepseek-r1-0528164KGA
deepseek-v3-0324128KGA
cohere-command-a128KGA
cohere-command-r-08-2024128KGA
cohere-command-r-plus-08-2024128KGA

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 gpt-4.1 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 "gpt-4o"

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": "gpt-4.1",
      "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).

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",
    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: "gpt-4o",
    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="gpt-4.1"
)

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/gpt-4.1 \
  --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 40 models, including 16 frontier and 24 open & specialized 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.