59API

← Retour aux guides

Your First Claude API Call in 5 Minutes

API · EN · 2026-07-09

Your First Claude API Call in 5 Minutes

If you want to test Claude without spending an afternoon reading documentation, this tutorial gets you from zero to a working API call in about five minutes. We will use 59API, an AI API relay that provides low-cost, pay-as-you-go access to Claude models such as Opus, Sonnet, Haiku, and Fable, plus GPT models through an OpenAI-compatible interface. That means you can use familiar tools, existing SDKs, and a single base URL: https://api.59api.com.

59API is especially useful for developers who want to prototype quickly, control costs, and avoid being locked into one vendor workflow. It is compatible with Claude Code, Codex, and any OpenAI SDK, while still routing to native official-quality models without downgrading. You can also benefit from its referral rebate if you share it with other developers.

Step 1: Create Your 59API Account

First, sign up for a 59API account and create an API key from your dashboard. Keep the key private: do not paste it into frontend JavaScript, GitHub issues, public repos, screenshots, or client-side mobile apps. For local testing, store it in an environment variable.

On macOS or Linux, you can set it like this in your terminal:

export API_KEY="your_59api_key_here"

On Windows PowerShell, use:

$env:API_KEY="your_59api_key_here"

If you do not have an account yet, this is a good moment to sign up for 59API and add a small pay-as-you-go balance so you can run the examples below without committing to a large plan.

Step 2: Choose a Claude Model

For your first request, choose a model based on what you need:

For a first call, Sonnet is a practical choice because it balances quality, speed, and cost. The exact model identifiers available to your account may appear in your 59API dashboard or model list, so use the name shown there.

Step 3: Make a Claude API Call with curl

The fastest test is a direct HTTP request. Because 59API is compatible with OpenAI-style chat completions, you can call the chat endpoint using the 59API base URL.

curl https://api.59api.com/v1/chat/completions -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -d '{"model":"claude-sonnet-4","messages":[{"role":"system","content":"You are a concise developer assistant."},{"role":"user","content":"Explain what an API relay is in one paragraph."}],"temperature":0.3}'

If everything is configured correctly, you should receive a JSON response containing the assistant message. If the model name differs in your account, replace claude-sonnet-4 with the model identifier listed by 59API.

Step 4: Call Claude from JavaScript

For most apps, you will use an SDK rather than raw curl. Since 59API works with any OpenAI SDK, you can point the client to the 59API base URL and keep the rest of your code familiar.

import OpenAI from "openai";

const client = new OpenAI({ apiKey: process.env.API_KEY, baseURL: "https://api.59api.com/v1" });

const response = await client.chat.completions.create({ model: "claude-sonnet-4", messages: [{ role: "user", content: "Write a short checklist for launching a Node.js API." }], temperature: 0.2 });

console.log(response.choices[0].message.content);

This pattern is convenient if you already use OpenAI-compatible tooling. You can switch models by changing the model value, not by rewriting your application.

Step 5: Call Claude from Python

The Python version is just as direct. Install the OpenAI Python package if you do not already have it, then configure the client with the same base URL.

from openai import OpenAI

client = OpenAI(api_key=os.environ["API_KEY"], base_url="https://api.59api.com/v1")

result = client.chat.completions.create(model="claude-sonnet-4", messages=[{"role":"user","content":"Give me three ideas for using Claude in a support dashboard."}], temperature=0.4)

print(result.choices[0].message.content)

In a production app, add retries for temporary network errors, log request IDs if provided, and set sensible timeouts. Also avoid sending secrets, passwords, or private customer data unless your compliance requirements are clearly addressed.

Step 6: Control Cost and Quality

A good Claude integration is not just about getting a response; it is about getting the right response at the right price. 59API is designed for cheap, pay-as-you-go access, which makes it easier to test multiple models before committing to one. Start with Haiku for high-volume simple tasks, use Sonnet as your default general-purpose model, and reserve Opus for the hardest prompts.

You can also reduce cost by keeping prompts focused, avoiding unnecessary chat history, setting a reasonable maximum output length when your SDK supports it, and caching repeated answers. For structured tasks, ask for a specific format and validate the result in your code.

Troubleshooting Your First Call

Next Steps

You now have a working Claude API call through 59API. From here, try building a small feature: a code reviewer, a customer support draft generator, a document summarizer, or a command-line assistant. Because 59API supports Claude and GPT models through OpenAI-compatible tooling, you can experiment quickly, compare quality, and keep costs predictable while using official-quality model access.

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