Skip to content

Android Studio

Last updated View as MarkdownAgent setup

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.

Prerequisites

Before you start, you need:

Configure the built-in AI assistant

  1. In Android Studio settings, go to Tools > AI > Model Providers.

  2. Select Add > Third-Party Remote Provider.

  3. For Description, enter a name such as Cloudflare AI Gateway.

  4. For URL, enter the following value. Replace <ACCOUNT_ID> and <GATEWAY_ID> with your Cloudflare account ID and gateway slug. You can use default as the gateway slug.

    https://gateway.ai.cloudflare.com/v1/<ACCOUNT_ID>/<GATEWAY_ID>/compat

    Enter the base URL without /chat/completions. Android Studio retrieves the model list before you select a model.

  5. For URL Schema, select OpenAI-compatible. For API key, enter your Cloudflare API token.

  6. 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.

  7. 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 ↗︎.

Configure GitHub Copilot Chat

Use a custom endpoint provider in GitHub Copilot Chat. Select Chat Completions explicitly for this configuration.

  1. Open GitHub Copilot Chat. In the model picker, select Manage Models.

  2. In Language Models (Copilot), select Add Models, then select the custom endpoint provider option.

  3. In Add Custom Endpoint Provider, enter the following values:

    • Provider Name: Cloudflare AI Gateway.
    • API Key: your Cloudflare API token.
    • API Type: Chat Completions.
  4. Select Save. In the Add Model dialog, enter a model ID in provider/model format. For example, enter openai/gpt-4.1-mini.

    Choose a model supported by your Unified Billing credits or stored provider keys.

  5. 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/completions

    Include /chat/completions. Unlike the built-in assistant, this field takes the full endpoint URL.

  6. 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. For openai/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.
  7. Select Save, then OK. Start a new Copilot chat and select your custom model from the model picker.

  8. 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.

Was this helpful?