Xcode

Last updated Oct 6, 2026 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.

Prerequisites

Before you start, you need:

Note

Service token requests do not include cf.user_id because they do not represent an individual Access user. You cannot filter AI Gateway logs by user for these requests.

  1. In Xcode, go to Xcode > Settings > Intelligence.
  2. Under Chat, select Add a Chat Provider > Internet Hosted.
  3. Enter a name for the provider, such as AI Gateway.
  4. For URL, enter your AI Gateway custom domain followed by /compat.

Replace ai.example.com with your custom domain.

txt https://ai.example.com/compat

Xcode appends /v1/models to list available models. It sends prompts to /v1/chat/completions. AI Gateway accepts both paths under the compat endpoint.

Note

The /compat endpoint is deprecated for standard single-model calls. Xcode requires an endpoint that supports both /v1/models and /v1/chat/completions. The AI Gateway REST API does not provide a /v1/models endpoint. 5. For API Key, enter the following single-header service token value. Replace <CLIENT_ID> and <CLIENT_SECRET> with your Access service token values.

json {"cf-access-client-id":"<CLIENT_ID>","cf-access-client-secret":"<CLIENT_SECRET>"}

  1. Set API Key Header to Authorization.
  2. Select Add.
  3. 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.

Was this helpful?

YesNo

On this page

Xcode - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/ai-gateway/integrations/coding-agents/xcode/#page","headline":"Xcode","description":"Route Xcode chat through an AI Gateway custom domain.","url":"https://developers.cloudflare.com/ai-gateway/integrations/coding-agents/xcode/","inLanguage":"en","image":"https://developers.cloudflare.com/ai-gateway/integrations/coding-agents/xcode/og.png?v=74d8ec766ecacf8a","dateModified":"2026-10-06","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}


description: Call AI Gateway from Pi AI with createAI from agents/models/pi-ai. title: Pi AI image: https://developers.cloudflare.com/ai-gateway/integrations/pi-ai/og.png?v=ae6beb0d263037eb


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/ai-gateway/llms.txt
Use this file to discover all available pages before exploring further.