> ## Documentation Index
> Fetch the complete documentation index at: https://docs.langdock.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect coding tools

> Use workspace models in Claude Code, Codex, Cursor, GitHub Copilot, OpenCode and Claude Desktop through the Langdock Model Gateway.

Coding tools that let you set a custom base URL and key can run on your workspace models through the Model Gateway. Requests count toward your spend limit and show up in your usage, and your workspace admin sees them per key.

## Before you start

* A personal **Model Gateway key**. See [API keys](https://docs.langdock.com/en/using-langdock/account/personal-api-keys.md).
* A model ID from **Available models** in [Settings > Account > API keys](https://app.langdock.com/settings/account/api-keys), or from `GET https://gateway.langdock.com/v1/models`.

When you create a Model Gateway key, **Use it in your tools** shows these steps with your key and the model you pick already filled in. Langdock shows the key only once, so finish the setup before you close the dialog, or keep the key in a password manager.

![Save your key dialog with the new key, a model picker set to Sonnet 5.5, a tool picker set to REST API and a curl request to gateway.langdock.com](https://mintcdn.com/langdock-34/50oda34lhL8TAAKF/images/model-gateway/member-gateway-key-created.png?fit=max\&auto=format\&n=50oda34lhL8TAAKF\&q=85\&s=9ba99f6aa238cb66b15915e88bc7c0e1)

Replace `YOUR_API_KEY` with your key and `your-model-id` with a model ID in the examples below. The gateway converts between formats, so every enabled model works in every tool, including Claude models in Codex and GPT models in Claude Code.

## Let your coding agent set it up

For Claude Code, Codex and OpenCode, switch **Setup method** to **Agent setup**. Langdock gives you a command that puts the key into a `LANGDOCK_API_KEY` environment variable in your terminal, and a prompt for the tool. Start the tool in that terminal and paste the prompt. The agent lists your models, sends a test request, backs up and updates the tool's config file and tells you what it changed. The prompt never contains the key itself.

## Set up a tool

> [tab] Claude Code
>
> Claude Code uses the Anthropic Messages format.
>
> **1. Check your models**
>
> ```bash theme={null}
> curl https://gateway.langdock.com/v1/models \
>   -H "Authorization: Bearer YOUR_API_KEY"
> ```
>
> **2. Add your settings**
>
> Add this to `~/.claude/settings.json` (Windows: `%USERPROFILE%\.claude\settings.json`) and create the file if it does not exist. Make sure `ANTHROPIC_API_KEY` is not set in your shell, because it takes precedence over the token:
>
> ```json theme={null}
> {
>   "env": {
>     "ANTHROPIC_BASE_URL": "https://gateway.langdock.com",
>     "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY",
>     "ANTHROPIC_MODEL": "your-model-id",
>     "ANTHROPIC_DEFAULT_HAIKU_MODEL": "your-model-id"
>   }
> }
> ```
>
> The base URL has no `/v1`, because Claude Code adds `/v1/messages` itself.
>
> **3. Start Claude Code**
>
> ```bash theme={null}
> claude
> ```
>
> Run `/status` to check that **Anthropic base URL** shows `https://gateway.langdock.com`. If you are signed in with a claude.ai account, run `/logout` first.

> [tab] Codex
>
> Codex uses the OpenAI Responses format.
>
> **1. Add your config**
>
> Add this to `~/.codex/config.toml` (Windows: `%USERPROFILE%\.codex\config.toml`) and create the file if it does not exist:
>
> ```toml theme={null}
> model = "your-model-id"
> model_provider = "workspace"
>
> [model_providers.workspace]
> name = "Langdock"
> base_url = "https://gateway.langdock.com/v1"
> wire_api = "responses"
> experimental_bearer_token = "YOUR_API_KEY"
> ```
>
> For models without hosted web search, which is every model except GPT-5, o3 and o4-mini served by OpenAI itself, **Use it in your tools** also adds `web_search = "disabled"` below `model_provider`. Keep that line, otherwise Codex sends a web search tool the model cannot run.
>
> **2. Start Codex**
>
> ```bash theme={null}
> codex
> ```
>
> Or open the Codex or ChatGPT desktop app.
>
> > [!TIP]
> >
> > To keep the key out of the file, replace `experimental_bearer_token = "YOUR_API_KEY"` with `env_key = "LANGDOCK_API_KEY"` and set that variable in your shell profile. The agent setup does it this way.

> [tab] Cursor
>
> Cursor uses the OpenAI Chat Completions format for Chat and Agent.
>
> **1. Add your key**
>
> Open **Cursor Settings > Models**, scroll down and expand **API Keys**. Paste your key into **OpenAI API Key** and turn on **Use OpenAI API Key**.
>
> **2. Set the base URL**
>
> Turn on **Override OpenAI Base URL** and enter:
>
> ```
> https://gateway.langdock.com/v1
> ```
>
> **3. Add the model**
>
> At the top of the **Models** page, add the model ID as a custom model. Claude and Gemini models need a provider prefix so Cursor sends them to the base URL above instead of its own Anthropic or Google key:
>
> ```
> anthropic/claude-model-id
> gemini/gemini-model-id
> gpt-model-id
> ```
>
> Restart Cursor and pick the model in a new Chat or Agent. A model without tool calling works in Chat only.
>
> Cursor calls the base URL from its own servers. While the override is on, Cursor's own OpenAI models also go through it, so turn it off to switch back. Tab completion keeps using Cursor's models.

> [tab] GitHub Copilot
>
> Copilot Chat in VS Code, agent mode and Copilot CLI use a dedicated Chat Completions route of the gateway. Pick a model that supports tool calling.
>
> **1. Add a custom endpoint in VS Code**
>
> Run **Chat: Manage Language Models** from the Command Palette. Choose **Add Models > Custom Endpoint**, use Langdock as the group name, paste your key and select **Chat Completions**.
>
> **2. Add the provider**
>
> VS Code opens `chatLanguageModels.json`. Add this provider or merge it with the ones you have, save, then pick the model in the Chat picker:
>
> ```json theme={null}
> [
>   {
>     "name": "Langdock",
>     "vendor": "customendpoint",
>     "apiKey": "YOUR_API_KEY",
>     "apiType": "chat-completions",
>     "models": [
>       {
>         "id": "your-model-id",
>         "name": "Your model",
>         "url": "https://gateway.langdock.com/v1/copilot/chat/completions",
>         "toolCalling": true,
>         "streaming": true
>       }
>     ]
>   }
> ]
> ```
>
> **3. Or use Copilot CLI**
>
> ```bash theme={null}
> export COPILOT_PROVIDER_BASE_URL="https://gateway.langdock.com/v1/copilot"
> export COPILOT_PROVIDER_API_KEY="YOUR_API_KEY"
> export COPILOT_MODEL="your-model-id"
> copilot
> ```
>
> Inline ghost text completions still use GitHub. Copilot Business and Enterprise organizations may need an admin to allow the **Bring Your Own Language Model Key** policy.

> [tab] OpenCode
>
> OpenCode 2 or later uses the Anthropic Messages format through the gateway.
>
> **1. Add your config**
>
> Add this to `opencode.json` in your project or to `~/.config/opencode/opencode.json` (Windows: `%USERPROFILE%\.config\opencode\opencode.json`). `model` sets the default model and replaces one you already set:
>
> ```json theme={null}
> {
>   "$schema": "https://opencode.ai/config.json",
>   "model": "workspace/your-model-id",
>   "providers": {
>     "workspace": {
>       "name": "Langdock",
>       "package": "@opencode/ai/providers/anthropic",
>       "settings": {
>         "baseURL": "https://gateway.langdock.com/v1"
>       },
>       "models": {
>         "your-model-id": { "name": "Your model" }
>       }
>     }
>   }
> }
> ```
>
> **2. Connect your key**
>
> In the same folder, run this and paste your key when asked. The key stays out of `opencode.json`:
>
> ```bash theme={null}
> opencode auth login workspace
> ```
>
> In the OpenCode app, run `/connect` and choose **Langdock** instead.
>
> **3. Start OpenCode**
>
> ```bash theme={null}
> opencode
> ```
>
> Switch models with `/models`.

> [tab] Claude Desktop
>
> Claude Desktop can run chats on workspace models through third party inference.
>
> **1. Enable Developer Mode**
>
> Open **Help > Troubleshooting > Enable Developer Mode**.
>
> **2. Configure the gateway**
>
> Open **Developer > Configure third-party inference**, set **Inference provider** to **Gateway** and enter under **Gateway credentials**:
>
> ```
> Gateway base URL:    https://gateway.langdock.com
> Gateway API key:     YOUR_API_KEY
> Gateway auth scheme: bearer
> Credential kind:     Static API key
> ```
>
> **3. Test and apply**
>
> Keep **Model discovery** on, click **Test connection** and **Test model discovery**, then **Save Changes** and **Apply Changes**. Choose **Continue with Gateway** if Claude asks after relaunching.

## On the classic endpoint

If your workspace does not have the Model Gateway yet, use your personal API key with the classic endpoint on `api.langdock.com`. Replace the gateway URLs like this:

| Model Gateway | Classic endpoint |
| - | - |
| `https://gateway.langdock.com/v1` (OpenAI formats) | `https://api.langdock.com/openai/eu/v1` |
| `https://gateway.langdock.com` (Claude Code, Claude Desktop) | `https://api.langdock.com/anthropic/eu` |
| `https://gateway.langdock.com/v1` (OpenCode) | `https://api.langdock.com/anthropic/eu/v1` |
| `https://gateway.langdock.com/v1/copilot/chat/completions` | `https://api.langdock.com/openai/eu/v1/chat/completions` |

Use `us` instead of `eu` for models hosted in the US. On dedicated deployments, replace `https://api.langdock.com` with `https://<your-domain>/api/public`. The classic endpoint does not convert formats, so:

* Claude Code, Claude Desktop and OpenCode work with Anthropic models only, Cursor and GitHub Copilot with OpenAI compatible models only.
* Cursor Agent does not work there, and Claude and Gemini models cannot be added to Cursor there.
* The classic Responses endpoint accepts only function tools, so Codex's built in tools are rejected there. Use Codex through the Model Gateway.

## Troubleshooting

| Symptom | Fix |
| - | - |
| `401` right away | The key is wrong, expired or revoked, or a second key from another variable is sent too. For Claude Code, unset `ANTHROPIC_API_KEY`. |
| `404` with a doubled path such as `/v1/v1/messages` | Remove `/v1` from the base URL of tools that add it themselves (Claude Code, Claude Desktop, the Anthropic SDK). |
| `404 model_not_found` | Use an ID from `GET /v1/models`. In Cursor, add the `anthropic/` or `gemini/` prefix for Claude and Gemini models. |
| `400` about `web_search` in Codex | Add `web_search = "disabled"` to `config.toml`. |
| `403 model_gateway_not_enabled` | The Model Gateway is not enabled for you yet. Use the classic endpoint. |
| `429` | You hit a rate limit or your spend limit. See [Errors](https://docs.langdock.com/en/developer/model-gateway/errors.md). |

More in [Errors and troubleshooting](https://docs.langdock.com/en/developer/model-gateway/errors.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.