Xcode integration
Claude, GPT, Gemini and Kimi in Xcode chat with Plan2API
Xcode 26.3 and Xcode 27 can chat with Claude, GPT, Gemini or Kimi through Plan2API: in Xcode > Settings > Intelligence, click Add a Chat Provider, choose Internet Hosted, enter https://api.plan2api.com with no /v1, set API Key Header to Authorization and API Key to Bearer followed by your p2a_ key.
- URL
- https://
api.plan2api.com - API Key Header
- Authorization
- API Key
- Bearer p2a_
your_ key - Minimum Xcode
- 26.3
Updated
Xcode chat provider settings at a glance
When you add Plan2API as an Internet Hosted provider, the dialog asks for four values. The table below shows what to enter in each field.
Leave /v1 off the URL, because Xcode adds /v1/models and /v1/chat/completions itself; a URL ending in /v1 or a trailing slash breaks the model list.
| Field | Value |
|---|---|
| Provider type | Internet Hosted |
| URL | https:// |
| API Key | Bearer p2a_ |
| API Key Header | Authorization |
| Description | Plan2API |
| Models | Loaded from /, star your favorites |
Add Plan2API to Xcode
- Sign up at Plan2API with a Google account, connect a subscription, and copy your
p2a_key. - Make sure you're running Xcode 26.3 or later, because 26.3 fixed a bug where custom model providers disappeared between launches of Xcode.
- Choose
Xcode > Settingsfrom the menu bar and selectIntelligencein the sidebar. - Under
Chat, clickAdd a Chat Provider(some Xcode 26 releases label this buttonAdd a Model Provider) and selectInternet Hosted. - Enter the
URL,API Keywith theBearerprefix and a space before your key,API Key Header, andDescriptionfrom the table above, then clickAdd. - Select
Plan2APIunderChatso Xcode fetches the model list, turn on the models you want to use, and star the ones you use most so they stay at the top of the menu. - Open a project, click the Coding Assistant button or press
Command-0, clickNew Conversation, and choose a Plan2API model underChat. - Send a short prompt to test the setup; the placeholder text in the message field names the model the conversation is using.
Pick a model for the coding assistant
Xcode's coding assistant only works with models that support tool calling and ideally have 200K tokens of context or more, and every Plan2API model supports tool calling.
claude/claude-sonnet-5uses a Claude Pro or Max subscription and has a 1M-token context window with up to 128K output.claude/claude-opus-5-5uses a Claude Pro or Max subscription and has a 1M-token context window with up to 128K output.openai/gpt-6.1-soluses a ChatGPT plan through Codex, so pick a Codex model your plan includes.gemini/gemini-3.8-flash-highuses a Google AI Pro or Ultra subscription and has a 1,048,576-token context window.kimi/k3uses a Kimi Code membership and has a 1,048,576-token context window, starting on the 256K window and moving to 1M when a conversation passes about 192K tokens.
Xcode lists every id returned by GET /v1/models, so star a few favorites in the provider settings to keep the model menu short.
Check the key outside Xcode
Xcode calls two endpoints on a chat provider: GET /v1/models for the model list and POST /v1/chat/completions for messages. The curl commands below send those exact requests using your key from the PLAN2API_KEY environment variable. If both requests return valid responses in your terminal, your key and connected subscription work, and any issue is in the Xcode dialog settings; if you get a 401 invalid_api_key error here, the key itself is wrong or missing.
# The two endpoints Xcode calls, with the same key and header
curl https://api.plan2api.com/v1/models \
-H "Authorization: Bearer $PLAN2API_KEY"
curl https://api.plan2api.com/v1/chat/completions \
-H "Authorization: Bearer $PLAN2API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "claude/claude-sonnet-5", "messages": [{"role": "user", "content": "Say ready"}]}'What works and what doesn't
- Chat conversations in the coding assistant work, and so do the source editor's coding tools (
Explain,Document,Generate a Playground,Generate a Preview, andGenerate Fix for Issue), which all send requests to your current chat model. - Tool calling and streaming work across Claude, Codex, Gemini, and Kimi models.
- Xcode's agents (
Claude Agent,Codex,Gemini, and agents added via the Agent Client Protocol withAdd an Agent) don't use chat providers and keep their own separate sign-in or configuration. - Xcode has no context-window setting for chat providers and keeps
Project Contexton by default, so turnProject Contextoff in the message field and reference specific files and symbols with@when you want to send smaller requests. - Each turn re-sends the whole conversation and project context, so start a new conversation when you move to a new task.
- On Plan2API's Free plan, every chat prompt and every coding-tool action in the source editor counts toward the limit of 50 chat requests a day.
Fix Xcode chat provider errors
When the Plan2API provider fails to load models or answer prompts, the cause is usually a value in the dialog or an account limit. The table below maps each symptom and error code to its fix.
If the model list is empty right after clicking Add, check the URL field for a trailing /v1 or slash first, and check the Bearer prefix in API Key second.
| Symptom | Cause | Fix |
|---|---|---|
| Provider gone after relaunch | Xcode older than 26.3 | Update Xcode, add the provider again |
| Empty model list | URL ends in / or / | Use https:// exactly |
401 invalid_ | Missing Bearer prefix or wrong key | Set API Key to Bearer p2a_ |
403 no_ | No subscription for that provider | Connect it or pick another model |
400 model_ | Model id changed or mistyped | Pick the model again from the list |
400 unsupported_ | JSON response_ on a Claude model | Use a GPT, Gemini or Kimi model |
429 daily_ | Free plan's 50 requests used | Wait for 00:00 UTC or upgrade |
| No coding assistant at all | MDM turned it off | Ask your Mac administrator |
Use your Claude or ChatGPT plan in Xcode
Plan2API turns a Claude Pro or Max, ChatGPT (through Codex), Google AI Pro or Ultra, or Kimi subscription you already pay for into one p2a_ API key, so one chat provider in Xcode can serve all four model families once each subscription is connected.
You keep paying your provider for your subscription, Plan2API never bills per token, and your subscription's own usage limits apply. If you connect several accounts from the same provider, a request that hits a limit on one account moves to the next connected account before any output is sent.
- Free: $0, 1 connected subscription, 50 chat requests a day (resets at 00:00 UTC), no card required.
- Pro: $12 a month or $99 a year, 3 connected subscriptions, no daily request cap.
- Scale: $29 a month or $249 a year, 25 connected subscriptions, no daily request cap; see pricing for full plan details.
Use the AI subscriptions you already pay for as one OpenAI-compatible API key.
- Free: 1 subscription, 50 requests a day, no card
- Pro: $12 a month
FAQ
What URL do I enter for Plan2API in Xcode?
Enter https://api.plan2api.com with no /v1 and no trailing slash. Xcode appends /v1/models and /v1/chat/completions to the URL on its own, so adding /v1 makes Xcode request /v1/v1/models.
Do I type Bearer in Xcode's API Key field?
Yes. When API Key Header is set to Authorization, Xcode sends the API Key field as the entire header value, so you need to enter Bearer, a space, and then your p2a_ key.
Can I use Claude in Xcode without Plan2API?
Yes, Xcode's Intelligence settings include a built-in Claude Sonnet & Opus option under Chat that uses its own sign-in. Plan2API is for when you want GPT, Gemini, and Kimi models alongside Claude in one chat provider, or want to use multiple connected accounts.
Does the Plan2API provider work with Claude Agent or Codex in Xcode?
No. Chat providers in Xcode power chat conversations and source editor coding tools only; Xcode's agents (Claude Agent, Codex, Gemini, and Agent Client Protocol agents) sign in or configure on their own.
Which Xcode version do I need?
Use Xcode 26.3 or later, because earlier Xcode 26 releases had a bug where custom model providers disappeared between launches. Xcode 26 through 26.3 require macOS Sequoia 15.6 or later, Xcode 26.4 through 26.6 require macOS Tahoe 26.2 or later, and Xcode 27 requires macOS Tahoe 26.6 or later on an Apple silicon Mac.
Sources
- Apple: setting up coding intelligencedeveloper.apple.com
- Apple: Xcode 26.3 release notesdeveloper.apple.com
- Apple: Xcode 27 release notesdeveloper.apple.com
- Apple: Xcode 26 release notesdeveloper.apple.com
- Venice: Xcode setup guidedocs.venice.ai
- Router One: Xcode chat provider guiderouter.one