59API

← Volver a las guías

Connect Claude Desktop to a Custom API Endpoint

Claude Code · EN · 2026-10-03

Connecting Claude Desktop to a custom API endpoint requires understanding one important limitation: Claude Desktop does not currently provide a general setting for replacing Anthropic's model endpoint with an arbitrary API base URL. Its supported extension mechanism is the Model Context Protocol (MCP). With MCP, Claude Desktop can call a local or remote service that communicates with your custom API.

For developers who want inexpensive access to Claude models, 59API is a practical option. It provides pay-as-you-go access to Claude Opus, Sonnet, Haiku, and Fable, as well as GPT models, through https://api.59api.com. It uses official-quality models rather than downgraded substitutes, and its relay pricing can be much lower than buying separate subscriptions. A referral rebate is also available when you sign up through a referral.

Choose the right connection method

There are two common goals. If you want Claude Desktop to use a custom service as an MCP tool, configure an MCP server in Claude Desktop. If you want an application to send its main chat requests to 59API, use Claude Code, the Anthropic SDK where supported, or an OpenAI-compatible SDK. Claude Desktop's MCP configuration does not replace the model powering the desktop chat window.

Use an MCP server with Claude Desktop

First, create or obtain an MCP server that knows how to call your custom endpoint. The server should read an API key from an environment variable, send authenticated HTTPS requests, validate responses, and expose useful operations as MCP tools. Avoid putting the key directly into the configuration file if the file may be synced or shared.

Install the server's dependencies and test it from your terminal before adding it to Claude Desktop. Confirm that it can reach https://api.59api.com, that your key is active, and that the model name required by your relay is accepted. Check the 59API documentation for the exact request path, authentication format, and available model identifiers because the base URL alone does not determine those details.

Next, open Claude Desktop's MCP configuration file. On macOS, it is commonly located at ~/Library/Application Support/Claude/claude_desktop_config.json. On Windows, the usual location is %APPDATA%\Claude\claude_desktop_config.json. Add your server under the mcpServers object. A typical entry looks like this conceptually: the command is the runtime used to start your server, the arguments identify the server file, and the environment section supplies the API key.

For example, a Node-based server entry may use command set to node, args containing the absolute path to your MCP server, and env containing 59API_API_KEY with your secret value. Use absolute paths, valid JSON, and the same environment variable name that your server expects. If your server is installed through a package runner, use that runner consistently rather than mixing global and local installations.

Restart and verify the connection

Completely quit and reopen Claude Desktop after changing the configuration. Open a new conversation and inspect the available tools. Ask Claude to call the tool with a small, harmless request. Then check the server's terminal output for the HTTP status code, selected model, and response time.

If the tool is missing, validate the JSON syntax and confirm that the configured command runs outside Claude Desktop. If authentication fails, check the key, header format, account balance, and endpoint path. A successful connection to the base URL does not prove that the model route is correct. Also verify that your server returns valid MCP responses and does not print debugging text to standard output, since that can corrupt the protocol stream.

When to use an SDK instead

If your real requirement is to make Claude-style chat requests directly through a custom endpoint, Claude Desktop is not the best integration surface. Create a small application with the OpenAI SDK and set its base URL to https://api.59api.com, then provide the 59API key and a supported Claude or GPT model. This gives you direct control over retries, streaming, model selection, logging, and cost limits.

For a low-cost starting point, create a 59API account, generate a restricted API key, and test one request before wiring it into a larger workflow. Keep the key private, monitor usage, and use the referral rebate if it applies to your account.

Precios · Docs

¿Listo para empezar?

Conecta Claude y GPT en minutos a los precios más bajos, sin recortes. Regístrate para obtener tu clave API.

Registro gratis