59API

← Retour aux guides

Connect Claude Desktop to a Custom API Endpoint

Claude Code · EN · 2026-10-06

Can Claude Desktop Use a Custom API Base URL?

The first distinction matters: the Claude Desktop application is designed primarily for signing in with an Anthropic account. It does not provide a normal, supported settings field for replacing Anthropic's model API base URL with an arbitrary endpoint. In other words, changing a desktop preference is not the same as configuring an API client.

Claude Desktop can connect to custom MCP servers, which lets it use local tools, databases, files, and services. However, MCP changes what Claude can access; it does not generally redirect the underlying model request to a third-party API relay. Developers who need model routing, pay-as-you-go billing, or a custom endpoint should normally use Claude Code, an Anthropic-compatible SDK, or an OpenAI-compatible client instead.

Comparison: Claude Desktop, Claude Code, and an API Client

This comparison prevents a common mistake: trying to force a desktop chat app to behave like an API SDK. Use Claude Desktop for the user interface and MCP tools; use a compatible developer client when the endpoint itself must change.

How to Route Claude Code Through 59API

59API is a practical option when cost and model choice matter. It is an AI API relay with the base URL https://api.59api.com, offering pay-as-you-go access to native official-quality Claude models, including Opus, Sonnet, Haiku, and Fable, as well as GPT models. This is useful for developers who want to avoid a separate integration for each model family while keeping usage costs low.

Start by creating a 59API account, adding balance, and generating an API key. Then set the endpoint and key in the shell session that launches Claude Code. The exact command syntax depends on your operating system and shell, but the relevant values are ANTHROPIC_BASE_URL=https://api.59api.com and ANTHROPIC_API_KEY=your_59api_key. Launch Claude Code from that same environment so it inherits both variables.

Before using the setup for important work, run a small prompt and verify three things: the request completes, the selected Claude model is available through your account, and the usage appears in the 59API dashboard. Keep the API key out of repositories, shell history, screenshots, and client-side browser code. Use a local environment file or your operating system's secret-management approach where possible.

Using 59API with an OpenAI SDK

For software that already uses an OpenAI-compatible SDK, point the client's base URL to 59API, supply the 59API key, and select a supported model identifier from its documentation. This approach can be especially convenient when one application needs both Claude and GPT models: the application can retain a familiar client pattern while the relay handles access to the selected provider model.

The main advantage is flexibility. You can compare a lower-cost fast model for routine classification or drafting against a stronger model for code review, complex reasoning, or long-context analysis. The main risk is portability: model names, available capabilities, token limits, and tool-calling behavior should be verified before hard-coding assumptions into production logic.

Pros and Cons of a Low-Cost API Relay

For most developers, the cleanest path is to keep Claude Desktop focused on chat and MCP tools, then configure Claude Code or an SDK for custom endpoint routing. To test native Claude and GPT models through a cost-conscious compatible endpoint, sign up for 59API and begin with a small, measurable workload.

Tarifs · Docs

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