Skip to main content

Documentation Index

Fetch the complete documentation index at: https://doc.hitopen.com/llms.txt

Use this file to discover all available pages before exploring further.

Channels are the upstream AI provider connections that Newapi routes requests through — for example, OpenAI, Anthropic, Azure OpenAI, or any compatible provider. Use these endpoints to add, configure, test, and remove channels programmatically.
All channel management endpoints require Admin or Root permission. Regular user accounts cannot access these endpoints. Authenticate with a system access token from Personal Settings → Security Settings → System Access Tokens.

Endpoints

MethodPathDescription
GET/api/channel/List all channels
POST/api/channel/Create a channel
GET/api/channel/{id}Get a single channel
PUT/api/channel/Update a channel
DELETE/api/channel/{id}Delete a channel
GET/api/channel/testTest all channels
GET/api/channel/test/{id}Test a specific channel

List all channels

GET /api/channel/
Returns a paginated list of all configured channels.

Query parameters

p
integer
Page number (1-indexed). Defaults to 1.
page_size
integer
Number of channels to return per page. Defaults to 10.
id_sort
boolean
When true, sorts results by channel ID instead of the default ordering.
tag_mode
boolean
When true, groups channels by tag in the response.
status
string
Filter by channel status. For example, "enabled" or "disabled".
type
integer
Filter by channel type identifier (corresponds to the provider type integer).

Example

curl -X GET "https://YOUR_NEWAPI_BASE_URL/api/channel/?p=1&page_size=20&status=enabled" \
  -H "Authorization: Bearer your-access-token"

Create a channel

POST /api/channel/
Adds one or more new upstream provider channels.

Request body

mode
string
The creation mode. One of:
  • "single" — create a single channel with one API key.
  • "batch" — create multiple channels, one per API key supplied.
  • "multi_to_single" — assign multiple API keys to a single channel.
channel
object
The channel configuration object. Fields vary by provider type. Common fields include:
  • name (string) — display name for the channel.
  • type (integer) — provider type identifier.
  • key (string) — API key or comma-separated list of keys (for batch/multi-key modes).
  • base_url (string) — custom base URL for the provider, if applicable.
  • models (string[]) — models this channel supports.
  • model_mapping (object) — maps request model names to provider-specific names.
  • priority (integer) — routing priority; higher values are preferred.
  • weight (integer) — weight for load balancing across channels with equal priority.

Example

curl -X POST "https://YOUR_NEWAPI_BASE_URL/api/channel/" \
  -H "Authorization: Bearer your-access-token" \
  -H "Content-Type: application/json" \
  -d '{
    "mode": "single",
    "channel": {
      "name": "OpenAI Production",
      "type": 1,
      "key": "sk-your-openai-key",
      "models": ["gpt-4o", "gpt-4o-mini", "gpt-3.5-turbo"],
      "priority": 10,
      "weight": 1
    }
  }'

Get a single channel

GET /api/channel/{id}
Returns the full configuration of a specific channel.

Path parameters

id
integer
required
The numeric ID of the channel to retrieve.

Example

curl -X GET "https://YOUR_NEWAPI_BASE_URL/api/channel/7" \
  -H "Authorization: Bearer your-access-token"

Update a channel

PUT /api/channel/
Updates an existing channel’s configuration. Include the id field in the request body along with any fields you want to change. Accepts the same fields as the channel object in create a channel, plus:
id
integer
required
The numeric ID of the channel to update.

Example

curl -X PUT "https://YOUR_NEWAPI_BASE_URL/api/channel/" \
  -H "Authorization: Bearer your-access-token" \
  -H "Content-Type: application/json" \
  -d '{
    "id": 7,
    "name": "OpenAI Production (updated)",
    "priority": 20
  }'

Delete a channel

DELETE /api/channel/{id}
Permanently removes the specified channel. Newapi will stop routing requests through this channel immediately.

Path parameters

id
integer
required
The numeric ID of the channel to delete.

Example

curl -X DELETE "https://YOUR_NEWAPI_BASE_URL/api/channel/7" \
  -H "Authorization: Bearer your-access-token"
Deleting a channel is irreversible. If this is the only channel for a particular model, requests to that model will fail until you add a replacement channel.

Test all channels

GET /api/channel/test
Sends a test request through every enabled channel and returns the results. This is useful for verifying connectivity and latency across all configured providers.
Testing all channels may take several seconds if you have many channels configured. Each channel is tested individually.

Example

curl -X GET "https://YOUR_NEWAPI_BASE_URL/api/channel/test" \
  -H "Authorization: Bearer your-access-token"

Test a specific channel

GET /api/channel/test/{id}
Sends a test request through a single channel and returns the result, including latency and any error details.

Path parameters

id
integer
required
The numeric ID of the channel to test.

Example

curl -X GET "https://YOUR_NEWAPI_BASE_URL/api/channel/test/7" \
  -H "Authorization: Bearer your-access-token"