Skip to main content
Admin › Settings › Code Gateway
Code Gateway is an enterprise proxy gateway that routes LLM API requests from AI coding CLI tools (Claude Code, Codex CLI, Gemini CLI, Cursor) through Cloosphere.
  • GitHub Copilot CLI and other OpenAI-compatible clients can also connect via the OpenAI endpoint.
Centralize the management of AI coding tool usage with guardrails, usage tracking, audit logs, and rate limits.
Code Gateway settings main screen

Code Gateway settings main screen


Concept

Code Gateway is backend-API-dedicated and operates separately from chat in the Cloosphere web UI. Configure only in admin settings — users set Cloosphere API keys in their coding tools.

Activation and Setup

Enabling Code Gateway

1

Open admin settings

Navigate to the Code Gateway settings page in the admin panel.
2

Activate the gateway

Toggle on Enable Code Gateway.
3

Add Provider

Click + Add Provider to register an LLM Provider.
4

Security settings

Configure allowed models, rate limits, guardrails, file pattern blocks.
Code Gateway activation and full settings

Code Gateway activation and full settings

Global Settings


Provider Settings

A Provider is the upstream LLM service Code Gateway forwards requests to.
  • Multiple Providers can be registered simultaneously, each identified by a unique provider_id.

Supported Providers

Provider Presets

Picking a preset when adding a Provider auto-sets the type and base URL.
Azure AI Foundry has two sub-presets:
  • Azure AI Foundry - OpenAI: For OpenAI-compatible models (openai type). Use with Cursor, Codex CLI, GitHub Copilot.
  • Azure AI Foundry - Claude: For Claude models (azure_ai_foundry type). Use with Claude Code, Cursor.
For the same AI Foundry endpoint, pick the appropriate preset based on the models you’re using.

Adding a Provider

Add Code Gateway Provider

Add Code Gateway Provider


Developer Usage

Developers set the BASE_URL of their AI coding tools to Cloosphere Code Gateway and use a Cloosphere API key.
Developer setup guide — per-tool BASE_URL

Developer setup guide — per-tool BASE_URL and API key

Endpoint Structure

Examples:
  • OpenAI Provider: https://cloosphere.company.com/api/v1/code-gateway/openai/v1/chat/completions
  • Anthropic Provider: https://cloosphere.company.com/api/v1/code-gateway/anthropic/v1/messages

Authentication

Code Gateway accepts API keys in four ways (in priority order).
Generate API keys under Settings › Account › API Keys › Create new secret key in Cloosphere. Use the Cloosphere API key, not the Provider’s original API key.

Per-Tool Setup Examples

Claude Code Setup Script

An auto-setup script is provided for Claude Code users.
  • It auto-installs the helper script and configures ~/.claude/settings.json.
What the setup script does:
  1. Install helper script (~/cloosphere-helper.sh or ~/cloosphere-helper.ps1): Auto-attach repository metadata (Git remote URL, working directory) to API keys
  2. Configure ~/.claude/settings.json: Auto-set ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL, apiKeyHelper
The helper script is required in environments with repository metadata-based blocking policies (blocked_repos, require_repo_metadata) enabled.

Security Features

The Security master toggle enables or disables the security checks below (guardrails, allowed models, file patterns, repository blocking) in bulk.
  • Turning on Follow global guardrail settings applies the global guardrail settings directly to Code Gateway without separate configuration.

Guardrails

Apply guardrails to Code Gateway for PII detection, content filtering, etc., on coding tool inputs. Guardrail violations, file pattern blocks, repository blocks, and other events are all viewable in the Monitoring > Guardrail Logs tab.

Allowed Models

Restrict to specific models.
  • Configurable at both global and Provider levels.
When both allowed_models (global) and model_ids (per Provider) are set, only models allowed by both are usable. allowed_models is the Code Gateway-wide policy; model_ids adds per-Provider restriction.

Rate Limit

Limit max requests per minute per user.
  • Operates on a 60-second sliding window.
Rate limits are in-memory, so they reset on server restart.

File Pattern Block

Block files matching specific patterns in coding tool requests.
  • Specify patterns in glob format.

Blocked Repositories

Block AI coding tool usage in specific Git repositories.
  • Matching is based on repository metadata (repo URL, working directory) passed via the helper script.
Patterns are case-insensitive substring matched against repository URL and working directory path. Git SSH URLs (git@github.com:org/repo.git) are auto-normalized for matching.
Blocked repository access is auto-recorded in the guardrail log.

Require Repository Metadata

Enabling require_repo_metadata blocks requests without repository metadata via the helper script.
  • This forces all Code Gateway users to set up the helper script.
Enabling this option blocks all requests from users without the helper script. Inform users to set up the helper script before enabling.

Usage Tracking

All requests through Code Gateway are auto-logged for usage.
  • Admins can review usage logs to see per-team, per-user, per-model usage.

Usage Statistics

View per-period usage statistics to analyze cost and trends.

Filters


Proxy Processing Flow

The full flow Code Gateway uses to process requests:

Troubleshooting

Code Gateway is disabled in admin settings. Ask an admin to enable it.
The user’s feature permissions don’t include Code Gateway access. Admin must enable features.code_gateway in group permission settings.
The provider_id in the request URL doesn’t match a registered Provider. Verify Provider ID.
The requested model isn’t in the global allowed models or the Provider’s allowed models list. Ask an admin to add the model.
You’ve exceeded the per-minute request limit. Wait briefly and retry.
require_repo_metadata is enabled but the helper script isn’t configured. Run the Claude Code setup script to install the helper script.
The request’s repository URL or working directory matches a blocked_repos pattern. Ask an admin for unblock.