Xcode ↗︎ supports internet-hosted chat providers that use the OpenAI Chat Completions API. Point a chat provider at an AI Gateway custom domain protected by Cloudflare Access. Xcode authenticates with an Access service token stored as its API key.
This integration uses static credentials. Xcode cannot use cloudflared to generate short-lived Access tokens.
Before you start, you need:
- An AI Gateway with a custom domain.
- Cloudflare Access enabled on the custom domain.
- An Access service token allowed by a Service Auth policy.
- The Access application configured to authenticate service tokens with the
Authorizationheader. - Unified Billing credits or a stored provider key for each model.
- Xcode installed and updated to the latest version.
-
In Xcode, go to Xcode > Settings > Intelligence.
-
Under Chat, select Add a Chat Provider > Internet Hosted.
-
Enter a name for the provider, such as
AI Gateway. -
For URL, enter your AI Gateway custom domain followed by
/compat.Replace
ai.example.comwith your custom domain.https://ai.example.com/compatXcode appends
/v1/modelsto list available models. It sends prompts to/v1/chat/completions. AI Gateway accepts both paths under thecompatendpoint. -
For API Key, enter the following single-header service token value. Replace
<CLIENT_ID>and<CLIENT_SECRET>with your Access service token values.{"cf-access-client-id":"<CLIENT_ID>","cf-access-client-secret":"<CLIENT_SECRET>"} -
Set API Key Header to
Authorization. -
Select Add.
-
Enable a model, then select it in the coding assistant and send a prompt. Requests now route through AI Gateway.
For more information about custom chat providers, refer to Setting up coding intelligence ↗︎.
To confirm traffic reaches AI Gateway, refer to Verify it works.