Android Studio ↗︎ supports custom model providers through its built-in AI assistant and the GitHub Copilot plugin ↗︎. Point a provider at AI Gateway's OpenAI-compatible endpoint to route requests through your gateway. Authenticate with a Cloudflare API token and use Unified Billing or a stored provider key to authenticate with the model provider.
Configure the assistant you use. The built-in AI assistant and GitHub Copilot Chat have separate provider settings.
Before you start, you need:
- Your Cloudflare account ID. To find it, refer to Find your account and zone IDs.
- An authenticated AI Gateway. You can use your account's
defaultgateway or create a gateway and use its slug. - A Cloudflare API token with Account > AI Gateway > Run permission.
- Unified Billing credits or a stored provider key for the models you select.
- Android Studio installed. For the built-in AI assistant, use a version with support for third-party remote model providers. For GitHub Copilot Chat, install the latest GitHub Copilot plugin ↗︎ and complete its sign-in flow.
-
In Android Studio settings, go to Tools > AI > Model Providers.
-
Select Add > Third-Party Remote Provider.
-
For Description, enter a name such as
Cloudflare AI Gateway. -
For URL, enter the following value. Replace
<ACCOUNT_ID>and<GATEWAY_ID>with your Cloudflare account ID and gateway slug. You can usedefaultas the gateway slug.https://gateway.ai.cloudflare.com/v1/<ACCOUNT_ID>/<GATEWAY_ID>/compatEnter the base URL without
/chat/completions. Android Studio retrieves the model list before you select a model. -
For URL Schema, select OpenAI-compatible. For API key, enter your Cloudflare API token.
-
Select Refresh to retrieve the model list. Select the models you want to use, then select OK to save your settings.
Choose models supported by your Unified Billing credits or stored provider keys. A model appearing in the list does not mean you have configured credentials for it.
-
Open the AI chat window. Use the model picker to select a model from your remote provider, then send a prompt.
Some specialized Android Studio AI features may not work with third-party models. For feature compatibility, refer to Use a remote model ↗︎.
Use a custom endpoint provider in GitHub Copilot Chat. Select Chat Completions explicitly for this configuration.
-
Open GitHub Copilot Chat. In the model picker, select Manage Models.
-
In Language Models (Copilot), select Add Models, then select the custom endpoint provider option.
-
In Add Custom Endpoint Provider, enter the following values:
- Provider Name:
Cloudflare AI Gateway. - API Key: your Cloudflare API token.
- API Type: Chat Completions.
- Provider Name:
-
Select Save. In the Add Model dialog, enter a model ID in
provider/modelformat. For example, enteropenai/gpt-4.1-mini.Choose a model supported by your Unified Billing credits or stored provider keys.
-
For Deployment URL, enter the following value. Replace
<ACCOUNT_ID>and<GATEWAY_ID>with your Cloudflare account ID and gateway slug:https://gateway.ai.cloudflare.com/v1/<ACCOUNT_ID>/<GATEWAY_ID>/compat/chat/completionsInclude
/chat/completions. Unlike the built-in assistant, this field takes the full endpoint URL. -
For Model Friendly Display Name, enter a name such as
GPT-4.1 mini via AI Gateway. Set the token limits and capabilities to match your model. Foropenai/gpt-4.1-mini, you can use the following settings:- Max Input Tokens:
128000. - Max Output Tokens:
16000. - Support Tool Calling: selected.
- Support Vision: selected.
- Custom Request Headers: not selected.
- Max Input Tokens:
-
Select Save, then OK. Start a new Copilot chat and select your custom model from the model picker.
-
Send a prompt such as
Reply with exactly: copilot-gateway-test. Confirm that Copilot displays the reply.
To confirm traffic reaches AI Gateway, refer to Verify it works.