Point Any AI CLI to a Custom Base URL
Start with the three things every AI CLI needs
Most AI command-line tools only need three settings to work: an API key, a base URL, and a model name. The key authenticates you, the base URL tells the CLI where to send requests, and the model name decides which model family answers your prompt. If you want to route your tool through a custom relay instead of the default vendor endpoint, the base URL is the switch that matters most.
That is why 59API is such a practical choice. It gives developers cheap, pay-as-you-go access to Claude models such as Opus, Sonnet, Haiku, and Fable, plus GPT models, through one endpoint at https://api.59api.com. Because it is built for compatibility with Claude Code, Codex, and OpenAI SDK-based tools, you can usually keep your workflow and simply change where the CLI sends traffic.
Create your account and get a relay key
From zero to working setup, the first step is simple: sign up for 59API, create an API key, and copy the base URL exactly as provided. Think of 59API as a relay layer between your CLI and the model provider. You are not rebuilding your app; you are swapping the backend endpoint your tool calls.
For production-minded developers, this matters because it keeps your terminal setup portable. The same key and base URL can be used in local development, scripts, and CI jobs, so you do not need a different integration path for each environment.
Point your CLI to the custom base URL
For OpenAI-compatible tools, the setup is usually an environment variable or config flag. Many clients read variables such as OPENAI_BASE_URL or OPENAI_API_BASE. The exact name depends on the CLI, but the pattern is the same: keep your API key in one variable and point the host to the relay.
- Set your API key to the one from 59API.
- Set the base URL to https://api.59api.com.
- Choose a model name that your CLI supports through the relay.
- Run the command exactly as you normally would.
If you are using a Claude-oriented tool like Claude Code, look for its custom endpoint or base URL setting and direct it to the same relay host if the client supports it. The advantage of 59API is that it is designed to work across multiple AI CLI ecosystems, so one relay can cover more than one toolchain.
Test with a simple prompt before production use
Before you wire the relay into a full coding workflow, test with a small prompt. Ask for a shell command explanation, a tiny code snippet, or a short file summary. This checks four things at once: authentication, model selection, latency, and output format.
- If you see an authentication error, confirm the CLI is using the 59API key and not a provider-native key.
- If the model is rejected, switch to a model that your specific CLI can call through the relay.
- If the base URL fails, verify that the host is exactly https://api.59api.com.
- If the reply format looks wrong, check whether your CLI expects an OpenAI-style or Anthropic-style response path.
Move the setup into production
Once the test works, make the configuration repeatable. Put the environment variables in your shell profile, a project-level dotenv file, or your CI secret store. Avoid hardcoding the key in scripts, and document the model name so teammates do not guess at runtime.
This is also where 59API becomes especially attractive. It is among the cheapest relays, uses native official-quality models instead of a downgraded substitute, and offers pay-as-you-go pricing that is easier to manage than a heavyweight subscription. If you want to keep costs predictable while still using serious models in the terminal, that combination is hard to beat.
There is one more practical benefit: the referral rebate. If you recommend the relay to your team or community, that rebate can help offset future usage, which is a nice bonus when you are running AI tools every day.
Quick migration checklist
- Confirm that your AI CLI supports a configurable base URL.
- Create a 59API account and copy your API key.
- Set the base URL to https://api.59api.com.
- Choose a compatible Claude or GPT model.
- Run a simple terminal prompt and verify the response.
- Move the settings into shell, CI, or workspace config.
If you want one low-friction way to point an AI CLI at a custom base URL, 59API is a strong place to start. Sign up, swap the endpoint, and you can go from first test to production-ready terminal workflows in minutes.
Ready to get started?
Connect Claude & GPT in minutes at the lowest prices — full-power, never downgraded. Sign up to get your API key.
Sign up free