Code
Closed beta:
lightning codeis in closed beta, and we're rolling it out to more people. If you'd like to take part, contact support@lightning.ai.
code.lightning.ai serves models for coding agents
through an OpenAI-compatible API at https://code.lightning.ai/v1. The
lightning code commands set up a coding tool to use it, or create an API key
for any other tool. Requests bill the organization you choose, which needs a
Pro, Teams or Enterprise plan.
The commands set up these tools:
| Tool | Name for the commands |
|---|---|
| OpenCode | opencode |
| pi | pi |
| Codex | codex |
| DeepSeek Harness | dsh |
| Cursor | cursor |
The same steps, with your organization filled in, are under Settings > Lightning Code, in a plan's Coding tools section.
Before you begin
- The Lightning CLI, signed in. Install or update it with
pip install -U lightning-sdkand runlightning login; see CLI. Wherepipis missing or refuses to install outside a virtual environment, as on recent Ubuntu releases, useuv tool install -U lightning-sdkinstead. On a machine without a browser, setLIGHTNING_USER_IDandLIGHTNING_API_KEYinstead of runninglightning login. - An organization on a Pro, Teams or Enterprise plan. Compare plans on the pricing page.
- The coding tool installed. Each tool's section below shows how. pi and DeepSeek Harness need Node.js 22.19 or newer.
Set up a tool
This adds Lightning as a model provider in the tool and creates an API key that bills your organization.
Run the setup with the tool's name, replacing
my-orgwith your organization's name:lightning code setup opencode --org my-orgWithout
--org, the command lists your organizations with their plans and asks which one pays. In scripts and other non-interactive shells,--orgis required.The output names the files it changed:
OpenCode now uses code.lightning.ai, billed to My Org [my-org]. Provider: lightning in ~/.config/opencode/opencode.json Key file: ~/.local/share/opencode/auth.json API key: opencode on my-laptop 2026-10-09 Default: lightning/deepseek-v4.1-flashStart the tool. Its section below says how.
For every tool, the setup:
- Adds a provider called
lightningand leaves the rest of the tool's config as it is, comments included. Before changing a config file you already had, it backs it up by appending.lightning-backupto its filename. Files that hold keys aren't copied. - Saves the API key where the tool keeps its own keys, not in a file you'd share or commit.
- Makes DeepSeek V4.1 Flash the default model only if you don't have one yet.
- Takes the model list from
https://code.lightning.ai/v1/models, so run the setup again to pick up new models.
Setup options
| Option | What it does |
|---|---|
--org |
Organization that pays, by name. |
--model |
Makes this model the default, for example glm-5.3. |
--dry-run |
Shows the changes to the config without writing anything or creating a key. |
--rotate-key |
Creates a new API key and revokes the old one. |
--force |
Replaces a Lightning setup that you added by hand. |
To bill a different organization, run the setup again with its name. This creates a key there and revokes the old one.
OpenCode
curl -fsSL https://opencode.ai/install | bash
lightning code setup opencode --org my-org
opencodeThe provider goes into ~/.config/opencode/opencode.json, or
opencode.jsonc if that's the file you have. The key goes into OpenCode's
~/.local/share/opencode/auth.json. If your config lists providers in
enabled_providers, the setup adds lightning to it. Switch models with
/models.
The installer adds opencode to your PATH in your shell's startup file, so
start it from a new terminal.
pi
curl -fsSL https://pi.dev/install.sh | sh
lightning code setup pi --org my-org
piThe provider goes into ~/.pi/agent/models.json, the key into pi's
auth.json and the default model into settings.json. When
PI_CODING_AGENT_DIR is set, all three are in that directory instead. Switch
models with /model.
The installer offers to install Node.js if yours is missing or too old. When
it offers to start pi, say no: pi has no models until you run the setup. Start
pi from a new terminal, so it's on your PATH.
Codex
npm install -g @openai/codex
lightning code setup codex --org my-org
codex --profile lightningCodex gets a profile of its own, ~/.codex/lightning.config.toml, which it
uses on top of your config.toml when you start it with --profile lightning.
Your usual Codex setup doesn't change. The profile holds the key, so only you
can read it. Pick another model with -m, for example
codex --profile lightning -m lightning-ai/glm-5.3.
Image input through Codex isn't supported yet. The other tools send images.
DeepSeek Harness
DeepSeek Harness needs Node.js 22.19 or newer. npm installs it on an older
Node.js without a warning, but then dsh exits without doing anything. Check
with node --version. In a Studio, run nvm install 22 first.
npm install -g @deepseek-ai/dsh
lightning code setup dsh --org my-org
dsh webThe provider and default model go into the web and headless profiles, in
~/.dsh/profiles/<profile>/cordis.patch.yml, next to your other entries. The
key goes into ~/.dsh/.credentials.yaml as LIGHTNING_CODE_API_KEY.
dsh web prints a local address with a token, such as
http://127.0.0.1:3080/?token=.... Open it in your browser and pick a
Lightning model under Model in the message box.
Cursor
Cursor's settings can't be changed from outside Cursor, so the setup creates a key and prints the steps to add it in Cursor. You need a paid Cursor plan.
lightning code setup cursor --org my-orgCursor now uses code.lightning.ai, billed to My Org [my-org].
API key: cursor on my-laptop 2026-10-09
Finish in Cursor (needs a paid Cursor plan):
1. Open Cursor Settings (Cmd+Shift+J on macOS, Ctrl+Shift+J elsewhere) and go to Models.
2. Under API Keys, paste this into OpenAI API Key and press Enter:
sk-lit-...
3. Turn on "Use OpenAI API Key".
4. Turn on "Override OpenAI Base URL" and enter:
https://code.lightning.ai/v1
5. At the top of Models, add these model names and make sure they're switched on:
lightning-ai/glm-5.3
lightning-ai/glm-5.3-flash
lightning-ai/deepseek-v4.1-flash
6. Open a new chat and pick lightning-ai/deepseek-v4.1-flash.The key is shown only this once. While the base URL override is on, Cursor
sends all OpenAI models to Lightning, so its own GPT and Auto models stop
working until you turn it off. Tab completion keeps using Cursor's models, and
the cursor-agent CLI can't use Lightning models.
Check the setup
lightning code statusOpenCode: billed to my-org
API key: opencode on my-laptop 2026-10-09 (01jexamplekey0000000000000)
Config: ~/.config/opencode/opencode.json
Default: lightning/deepseek-v4.1-flash
pi: not set up
Codex: billed to my-org
...Add --json for machine-readable output.
Remove the setup
lightning code remove opencodeThis removes the lightning provider, a default model that uses it, and the API
key, which it also revokes. Files the setup created are deleted, and the rest of
your config stays as it is. To leave the key active, add --keep-key. For
Cursor, the command revokes the key and prints how to turn the override off.
Use other tools
For tools that speak the OpenAI API, create a key with lightning code token
and point the tool at https://code.lightning.ai/v1:
export OPENAI_BASE_URL=https://code.lightning.ai/v1
export OPENAI_API_KEY=$(lightning code token --org my-org)The key is printed once, so store it straight away. Name it with --name, or add
--json to get the key with its ID, organization and base URL.
Requests name the model by its full ID:
| Model | ID | Context window | Image input |
|---|---|---|---|
| GLM-5.3 | lightning-ai/glm-5.3 |
1,048,576 | No |
| GLM-5.3 Flash | lightning-ai/glm-5.3-flash |
253,952 | Yes |
| DeepSeek V4.1 Flash | lightning-ai/deepseek-v4.1-flash |
253,952 | Yes |
For the current list, with each model's output limit and supported parameters,
request https://code.lightning.ai/v1/models. It doesn't need a key.
Keys from lightning code are listed and deleted with lightning api-key.
Troubleshooting
... is on the Free plan, which doesn't include code.lightning.ai. The
organization needs a Pro, Teams or Enterprise plan. Upgrade it with the link in
the message, or pass another organization to --org.
Coding tools are turned off for ... An organization admin has turned off
coding tools. Ask them to turn them back on, or pass another organization to
--org.
... already has a Lightning setup that lightning code didn't make. You
added one by hand, for example from another guide. Run the setup again with
--force to replace it. Config files are backed up first.
No such command 'code', or Invalid value for 'TOOL'. Your Lightning CLI
is too old. Update it with pip install -U lightning-sdk.
See also
Was this page helpful?
Thanks for the feedback.