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.

Xcode Internet Hosted provider values for Plan2API
FieldValue
Provider typeInternet Hosted
URLhttps://api.plan2api.com
API KeyBearer p2a_your_key
API Key HeaderAuthorization
DescriptionPlan2API
ModelsLoaded from /v1/models, star your favorites

Add Plan2API to Xcode

  1. Sign up at Plan2API with a Google account, connect a subscription, and copy your p2a_ key.
  2. 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.
  3. Choose Xcode > Settings from the menu bar and select Intelligence in the sidebar.
  4. Under Chat, click Add a Chat Provider (some Xcode 26 releases label this button Add a Model Provider) and select Internet Hosted.
  5. Enter the URL, API Key with the Bearer prefix and a space before your key, API Key Header, and Description from the table above, then click Add.
  6. Select Plan2API under Chat so 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.
  7. Open a project, click the Coding Assistant button or press Command-0, click New Conversation, and choose a Plan2API model under Chat.
  8. 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-5 uses a Claude Pro or Max subscription and has a 1M-token context window with up to 128K output.
  • claude/claude-opus-5-5 uses a Claude Pro or Max subscription and has a 1M-token context window with up to 128K output.
  • openai/gpt-6.1-sol uses a ChatGPT plan through Codex, so pick a Codex model your plan includes.
  • gemini/gemini-3.8-flash-high uses a Google AI Pro or Ultra subscription and has a 1,048,576-token context window.
  • kimi/k3 uses 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.

curl
# 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, and Generate 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 with Add 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 Context on by default, so turn Project Context off 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.

Xcode chat provider errors with Plan2API
SymptomCauseFix
Provider gone after relaunchXcode older than 26.3Update Xcode, add the provider again
Empty model listURL ends in /v1 or /Use https://api.plan2api.com exactly
401 invalid_api_keyMissing Bearer prefix or wrong keySet API Key to Bearer p2a_...
403 no_credentialsNo subscription for that providerConnect it or pick another model
400 model_not_foundModel id changed or mistypedPick the model again from the list
400 unsupported_parameterJSON response_format on a Claude modelUse a GPT, Gemini or Kimi model
429 daily_requestsFree plan's 50 requests usedWait for 00:00 UTC or upgrade
No coding assistant at allMDM turned it offAsk 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

  1. Apple: setting up coding intelligencedeveloper.apple.com
  2. Apple: Xcode 26.3 release notesdeveloper.apple.com
  3. Apple: Xcode 27 release notesdeveloper.apple.com
  4. Apple: Xcode 26 release notesdeveloper.apple.com
  5. Venice: Xcode setup guidedocs.venice.ai
  6. Router One: Xcode chat provider guiderouter.one