Connect CLIProxyAPI to Apertis

Add Apertis as a paid multi-provider upstream while keeping the local CLIProxyAPI endpoint and client workflow you already use.

Before you configure the upstream

  1. Create an Apertis account.
  2. Choose a current Coding Plan or add PAYG balance in Credits.
  3. Create a scoped upstream key in API Keys. Keep it out of source control and logs.

No card is required to create an account. Choose a Coding Plan or add PAYG balance before your first API request.

Configure the Apertis upstream

Add an openai-compatibility provider to the CLIProxyAPI configuration. The apertis prefix keeps these models explicit when the proxy also has OAuth or other upstream accounts. Compare this example with the official CLIProxyAPI configuration for the installed version.

openai-compatibility:
  - name: "apertis"
    prefix: "apertis"
    base-url: "https://api.apertis.ai/v1"
    api-key-entries:
      - api-key: "YOUR_APERTIS_API_KEY"
    models:
      - name: "YOUR_MODEL_ID"
        alias: "YOUR_MODEL_ID"

Replace YOUR_MODEL_ID with an exact current ID from the live model catalog. Add more model entries only after verifying each one.

Use either SDK in both response modes

Apertis supports OpenAI SDK and Anthropic SDK requests, with both streaming and non-streaming responses. Through CLIProxyAPI, point the SDK at the local compatible endpoint and use the prefixed model name. Port 8317 is the CLIProxyAPI default; use the configured local port if you changed it.

OpenAI-compatible clients use http://localhost:8317/v1. Anthropic SDK clients use http://localhost:8317 because the SDK appends /v1/messages.

OpenAI SDK · Non-streaming

from openai import OpenAI

client = OpenAI(
    api_key="YOUR_LOCAL_PROXY_KEY",
    base_url="http://localhost:8317/v1",
)
response = client.chat.completions.create(
    model="apertis/YOUR_MODEL_ID",
    messages=[{"role": "user", "content": "Reply with OK"}],
    stream=False,
)
print(response.choices[0].message.content)

OpenAI SDK · Streaming

from openai import OpenAI

client = OpenAI(
    api_key="YOUR_LOCAL_PROXY_KEY",
    base_url="http://localhost:8317/v1",
)
stream = client.chat.completions.create(
    model="apertis/YOUR_MODEL_ID",
    messages=[{"role": "user", "content": "Reply with OK"}],
    stream=True,
)
for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

Anthropic SDK · Non-streaming

from anthropic import Anthropic

client = Anthropic(
    api_key="YOUR_LOCAL_PROXY_KEY",
    base_url="http://localhost:8317",
)
message = client.messages.create(
    model="apertis/YOUR_MODEL_ID",
    max_tokens=128,
    messages=[{"role": "user", "content": "Reply with OK"}],
)
print(message.content[0].text)

Anthropic SDK · Streaming

from anthropic import Anthropic

client = Anthropic(
    api_key="YOUR_LOCAL_PROXY_KEY",
    base_url="http://localhost:8317",
)
with client.messages.stream(
    model="apertis/YOUR_MODEL_ID",
    max_tokens=128,
    messages=[{"role": "user", "content": "Reply with OK"}],
) as stream:
    for text in stream.text_stream:
        print(text, end="")

Verify the routed request

Run one non-streaming request first, then its streaming equivalent. A completed setup is a model response followed by a matching request record in Activity. Repeat the check with the second SDK before moving a larger workload.

Create your Apertis account, then validate the response modes and their Activity records.