Which AI Platforms Are Supported by Sub2API’s Composite Groups?

Sub2API’s Composite Groups support Anthropic, Gemini, OpenAI, Antigravity, and Grok, routing requests dynamically based on model identifiers rather than binding API keys to a single provider.

Sub2API’s Composite Groups provide an admin-level routing layer that decouples API keys from specific providers. According to the Wei-Shaw/sub2api source code, this architecture enables automatic provider selection based on the public model identifier, influencing account selection, quota checks, billing, and usage reporting across multiple AI platforms.

Supported AI Platforms in Composite Groups

Composite Groups can route traffic to five built-in concrete platforms. Each platform maps to specific model naming patterns:

Platform Model Prefixes Description
Anthropic claude-*, anthropic/claude-* Routes requests to Claude models.
Gemini gemini-*, google/gemini-* Routes requests to Google Gemini models.
OpenAI gpt-*, codex-*, text-embedding-*, dall-e-*, openai/* Routes requests to OpenAI models.
Antigravity Custom prefixes Internal platform for experimental or custom providers.
Grok grok-*, xai/grok-* Routes requests to xAI’s Grok models.

This provider list is documented in docs/COMPOSITE_GROUPS.md lines 10-16, which serves as the primary specification for composite routing logic.

How Composite Group Routing Works

The routing system operates through three distinct mechanisms defined in the composite groups specification.

Route Registry Configuration

Admins configure explicit routes that map public model names to concrete platforms via the target_platform field. Each route definition includes the upstream model name, endpoint type, match type, priority, and enabled flag.

Key route parameters include:

  • public_model – The model identifier exposed to API consumers.
  • target_platform – The concrete provider (e.g., openai, anthropic).
  • match_type – Either exact or prefix matching.
  • priority – Lower values indicate higher precedence.
  • endpoint – Specific endpoint type or any.

Built-In Pattern Detection

When no explicit route matches, the system falls back to pattern-based detection that automatically maps common model prefixes to providers. This built-in detection handles standard naming conventions like gpt-* → OpenAI without requiring manual route configuration for every model variant.

The detection rules are specified in docs/COMPOSITE_GROUPS.md lines 64-70.

Resolution Order Logic

The router applies a strict resolution hierarchy when multiple routes could match:

  1. Explicit routes over built-in detection.
  2. Exact matches over prefix matches.
  3. Endpoint-specific routes over generic any routes.
  4. Lower priority values (numerically smaller) over higher ones.
  5. Lower route IDs as final tiebreaker.

This algorithm is implemented in the resolution logic documented at lines 46-49 of the composite groups specification.

Admin API Examples for Composite Groups

The following examples demonstrate the Admin API contract for managing composite groups and their routing rules.

Creating a Composite Group

POST /api/v1/admin/groups
Content-Type: application/json

{
  "name": "Premium Composite",
  "platform": "composite",
  "subscription_type": "subscription"
}

Adding a Route to a Group

POST /api/v1/admin/groups/{group_id}/composite-routes
Content-Type: application/json

{
  "public_model": "all/gpt-5",
  "match_type": "exact",
  "target_platform": "openai",
  "upstream_model": "gpt-5",
  "endpoint": "responses",
  "priority": 10,
  "enabled": true
}

Listing Existing Routes

GET /api/v1/admin/groups/{group_id}/composite-routes

Previewing Routes Before Committing

POST /api/v1/admin/groups/{group_id}/composite-routes/preview
Content-Type: application/json

{
  "public_model": "all/grok",
  "target_platform": "grok",
  "upstream_model": "grok-4.3"
}

These endpoints reflect the API contract described in docs/COMPOSITE_GROUPS.md lines 24-32.

Implementation Files and Architecture

The composite routing functionality spans backend and frontend components:

File Purpose
docs/COMPOSITE_GROUPS.md Primary specification documenting supported providers, routing logic, and admin API endpoints.
backend/router/composite_routes.go Implements runtime routing, matches public models to concrete platforms, and applies resolution order.
backend/models/group.go Defines the Group struct, including the platform field set to "composite" for composite groups.
frontend/src/components/admin/CompositeGroup.vue UI component for creating and managing composite groups in the admin console.

Summary

  • Sub2API Composite Groups support five AI platforms: Anthropic, Gemini, OpenAI, Antigravity, and Grok.
  • Routing decisions are based on model identifier patterns (e.g., claude-*, gpt-*) rather than static API key bindings.
  • The system uses a three-tier resolution process: explicit routes → built-in detection → resolution order logic.
  • Admins configure routing via REST API endpoints at /api/v1/admin/groups/{group_id}/composite-routes.
  • Core implementation resides in docs/COMPOSITE_GROUPS.md, backend/router/composite_routes.go, and backend/models/group.go.

Frequently Asked Questions

What is the difference between a regular group and a Composite Group in Sub2API?

A regular group binds API keys to a single concrete provider, while a Composite Group acts as a routing layer that can dynamically select from multiple providers (Anthropic, OpenAI, Gemini, etc.) based on the model identifier in the request. This enables unified API access across different AI platforms under a single group configuration.

How does Sub2API determine which provider to use for a given request?

The system first checks explicit routes configured in the Route Registry for exact or prefix matches on the public_model field. If no route matches, it falls back to built-in pattern detection that maps standard model prefixes (like gpt-* or claude-*) to their respective providers according to the resolution order defined in docs/COMPOSITE_GROUPS.md.

Can I route the same public model to different providers based on the endpoint?

Yes. When configuring routes via the Admin API, you can specify the endpoint parameter (e.g., responses, completions) to create endpoint-specific routing rules. The resolution order prioritizes endpoint-specific routes over generic any endpoint routes, allowing fine-grained control over provider selection.

What is the Antigravity platform used for?

Antigravity is an internal platform within Sub2API designated for experimental or custom providers. It allows administrators to test new model integrations or route traffic to proprietary endpoints that are not part of the standard Anthropic, Gemini, OpenAI, or Grok platforms.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →