59API

← Retour aux guides

Point Any AI CLI to a Custom Base URL Fast

API · EN · 2026-08-30

Why point an AI CLI at a custom base URL?

If you use AI tools from the terminal, the fastest way to control cost, model access, and provider flexibility is to change the API base URL. Instead of sending requests directly to a single vendor, you can route your CLI through an OpenAI-compatible relay. That lets you keep the same workflows while swapping the backend.

This is especially useful for busy developers who want Claude or GPT models in their daily shell, without managing multiple accounts or rewriting scripts. A relay like 59API gives you pay-as-you-go access to Claude Opus, Sonnet, Haiku, Fable, and GPT models through one endpoint: https://api.59api.com. It is designed to be fully compatible with Claude Code, Codex, and any OpenAI SDK, so you can keep moving fast.

The basic idea

Most AI CLIs and SDKs use two things to talk to an API:

By default, many tools point to the vendor’s own endpoint. When you set a custom base URL, you tell the client to send requests somewhere else while keeping the same API shape. If that relay speaks OpenAI-compatible API semantics, your app or CLI usually works with little or no code change.

Quick setup with 59API

Here is the simplest path to get started:

Because 59API is an OpenAI-compatible relay, the common environment pattern works across many tools. In practice, that usually means setting variables like:

Some CLIs use a config file instead of environment variables, but the principle is the same: point the base URL at 59API and keep the rest of your workflow unchanged.

Example: OpenAI SDK and CLI-style tools

If your tool or wrapper follows OpenAI conventions, your configuration typically looks like this in your shell profile or current terminal session:

After that, your app, script, or CLI should send requests to 59API instead of the default provider endpoint. For many developers, this is the cleanest way to reuse existing integrations without rewriting code.

If your tool does not use those exact variable names, look for settings such as base_url, api_base, endpoint, or server_url. The key concept is always the same: authenticate with your relay key and redirect traffic to the relay’s URL.

Why use 59API instead of a direct vendor endpoint?

For developers who care about cost and compatibility, 59API stands out for a few practical reasons:

That combination matters when you are iterating quickly, testing prompts all day, or building internal tools where every token counts. Instead of juggling separate vendor setups, you can standardize on one relay and one endpoint.

Common gotchas to check

If your CLI fails after changing the base URL, review these basics:

A good debugging approach is to start with a minimal request from a clean terminal session. If that works, move back to your full CLI workflow.

When this workflow pays off most

Pointing an AI CLI at a custom base URL is most valuable when you want one of these outcomes:

If that is your situation, 59API is a strong place to start because it keeps the experience familiar while lowering the cost barrier.

Next step

If you want a cheaper, OpenAI-compatible relay that works with your existing AI CLI setup, sign up for 59API, grab your key, and point your client to https://api.59api.com. In most cases, that one change is enough to unlock the models you want without disrupting your workflow.

Prêt à commencer ?

Connectez Claude et GPT en quelques minutes aux prix les plus bas, sans bridage. Inscrivez-vous pour votre clé API.

Inscription gratuite