# Connect JetBrains AI Assistant to Tokens

> Add Tokens as an OpenAI-compatible provider in JetBrains AI Assistant for chat, and optionally for inline completion. Covers the URL field, tool calling and the known path bug.

JetBrains AI Assistant is the AI plugin for IntelliJ IDEA, PyCharm, WebStorm and the other JetBrains IDEs. Besides JetBrains' own subscription, it can use your own API key with a third-party provider. Tokens fits the **OpenAI-compatible** provider type, which sends OpenAI Chat Completions requests to `https://tokens.bd/v1`. The models then appear in the AI Chat model selector.

This guide was checked against JetBrains' AI Assistant 2026.2 documentation (the providers page is dated 15 July 2026 and the overview 5 August 2026; read October 2026). It was checked against the documentation, not run end to end with a live key.

:::note[This is not the same as Claude Code or Junie in JetBrains]
AI Assistant also hosts coding agents (Junie, Claude Agent, Codex, GitHub Copilot and agents added through the Agent Client Protocol). Those agents are separate from the OpenAI-compatible provider described here, and JetBrains' provider pages do not say that they use it. To run Claude Code through Tokens, follow [Claude Code](/docs/claude-code) and its own settings instead. For an open-source assistant that you configure in a file, see [Continue](/docs/continue), which also runs in JetBrains IDEs.
:::

## What you need

- A JetBrains IDE with AI Assistant installed. JetBrains lists CLion, DataGrip, DataSpell, GoLand, IntelliJ IDEA, PhpStorm, PyCharm, Rider, RubyMine, RustRover and WebStorm. Use version 2026.1.2 or later (see the path bug below).
- A Tokens key. [API keys](/docs/api-keys) covers spend caps and allow-lists.
- A model id from the [model catalog](/models). This guide uses `deepseek/deepseek-v4.1-flash`.

If your organization uses JetBrains IDE Services or JetBrains Central, JetBrains says an administrator can restrict providers or block your own API keys. If the settings below are missing, ask your admin.

## Add Tokens as a provider

1. Open **Settings** and go to **Tools | AI Assistant | Providers & API keys**.
2. In **Third-party AI providers**, set **Provider** to **OpenAI-compatible**.
3. In **URL**, enter `https://tokens.bd/v1`.
4. In **API Key**, paste your Tokens key.
5. Set **Tool calling** on or off (see below).
6. Click **Test Connection**, then **Apply**.
7. Open AI Chat and click the model selector. Your Tokens models are listed under the provider's section.

### Which URL to enter

JetBrains' pages say only "Specify the URL of the provider's API endpoint". They give no example that includes or leaves out `/v1`, and they do not say whether the field takes a path.

Enter `https://tokens.bd/v1`, which ends in `/v1` and has no `/chat/completions`. The reasons:

- Two bug reports in JetBrains' tracker show the IDE building the model-list request itself. In LLM-22721 a custom path was ignored and the IDE asked for `/api/v1/models` (closed as a duplicate). In LLM-22911 a base URL ending in `/v4/` was rewritten to `/v1`. JetBrains lists LLM-22911 as fixed in 2026.1.2.
- Tokens serves the model list at `https://tokens.bd/v1/models`, so a URL that ends in `/v1` gives the right path whether the IDE keeps your path or replaces it with `/v1`.

If Test Connection fails and the Tokens request log shows a 404 `unsupported_endpoint` with a doubled path such as `/v1/v1/models`, the IDE is adding `/v1` itself. Try `https://tokens.bd` (the same host without `/v1`) instead. This fallback is an inference from the bug reports, not something JetBrains documents.

JetBrains' pages do not say how the model list is built, but the bug reports above show the IDE requesting `/models`. Tokens serves it filtered by key, plan and wallet, so a key with an allow-list shows only the allowed models.

### Tool calling

JetBrains describes the **Tool calling** setting as whether the model supports calling tools configured through MCP, and it appears only for OpenAI-compatible providers. Turn it on for a model that supports tool calling (check [Choosing a model](/docs/choosing-a-model)) if you use MCP servers in AI Chat. Leave it off for a model that does not. JetBrains' page does not document tool use outside MCP.

## Use Tokens for inline completion

AI Completion (inline completion and next edit suggestions) has its own provider setting.

1. In the same settings page, find the **AI Completion** section and set **Provider** to **OpenAI Compatible**.
2. Enter your Tokens key as **API key** and `https://tokens.bd/v1` as **Base URL**.
3. Enter the **Model**, **Model context**, **Max output tokens** and **Prompt schema**, then click **Test Connection** and **Apply**.

JetBrains says the model must be served by the endpoint in Base URL, and that inline completion needs a model with Fill-in-the-Middle (FIM) support. Next edit suggestions need edit-prediction support. Most chat models in the catalog are not FIM models, so check the [catalog](/models) before pointing completion at Tokens. Completion fires on short pauses while you type, which adds up on a metered key and against the per-minute rate limit. Use a separate key with a spend cap.

## Models Assignment

For local models and OpenAI-compatible endpoints, JetBrains asks you to assign models to feature groups yourself under **Models Assignment**:

| Group             | Used for, per JetBrains                                           |
| ----------------- | ----------------------------------------------------------------- |
| Core features     | In-editor code generation and commit message generation          |
| Instant helpers   | Chat context collection, chat title generation and name suggestions |

The page also shows a **Context window** field, which defaults to 64 000 tokens for local models. Set it to the context window listed for your model in the [catalog](/models) so long chats are not cut short.

## Check that it works

Test the key and model outside the IDE first:

```bash
export TOKENS_API_KEY=tok_live_your_key
curl -s https://tokens.bd/v1/models -H "Authorization: Bearer $TOKENS_API_KEY"
curl -s https://tokens.bd/v1/chat/completions \
  -H "Authorization: Bearer $TOKENS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "deepseek/deepseek-v4.1-flash", "max_tokens": 16, "messages": [{"role": "user", "content": "Reply with OK"}]}'
```

Then click **Test Connection** in the IDE, pick the Tokens model in AI Chat and send a message. The request appears in your dashboard usage analytics.

## Limits and what does not work

- JetBrains' provider pages do not mention agents. Junie, Claude Agent and the other agents are configured separately.
- JetBrains states that AI Assistant does not support invoking tools from configured MCP servers when using local models. The page makes no such statement for OpenAI-compatible endpoints, but it also does not confirm that every tool-calling feature works there.
- If a feature has no model assigned that supports it, JetBrains can fall back to a JetBrains AI subscription, if you have one.
- The model-selector list is only as complete as `GET /v1/models` for your key.

## Troubleshooting

**Test Connection fails.** Check the URL first (see above), then the key. Run the `curl` commands above to separate a Tokens problem from an IDE problem. If you are on a version older than 2026.1.2, update, because older builds could replace the path.

**401 `invalid_api_key` or `missing_api_key`.** The key is wrong, was left empty, or was rotated. Rotation stops the old secret immediately. Paste the new key and apply again.

**The model list is empty.** An empty `data` array usually means no active plan and no wallet balance, or an allow-list that excludes every model. Subscribe or top up in [billing](/dashboard/billing).

**404 `model_not_found`.** The model id must be the full Tokens id, including the provider prefix and the slash, such as `deepseek/deepseek-v4.1-flash`.

**Errors after turning Tool calling on.** A 400 `invalid_request` can mean the upstream rejected the tool definitions. Turn the setting off or choose a model that supports tools.

**402 `insufficient_credits` or 429 `rate_limited`.** Top up in [billing](/dashboard/billing), or wait for `Retry-After`. Inline completion is the usual cause of rate limits.

Every code is listed in [Errors](/docs/errors), and the request format is in [Chat Completions](/docs/chat-completions).

Sources: JetBrains AI Assistant help, [Providers and API keys](https://www.jetbrains.com/help/ai-assistant/settings-reference-providers-and-api-keys.html), [Use custom models](https://www.jetbrains.com/help/ai-assistant/use-custom-models.html), [Agents](https://www.jetbrains.com/help/ai-assistant/agents.html), tracker issues [LLM-22911](https://youtrack.jetbrains.com/projects/LLM/issues/LLM-22911) and [LLM-22721](https://youtrack.jetbrains.com/projects/LLM/issues/LLM-22721), checked October 2026.

---
Page: https://tokens.bd/docs/jetbrains-ai-assistant
