Find an API

Search public APIs with auth details & Postman guides

← All APIs

Anthropic Claude API

api.anthropic.com · AI

AI API Key Paid AI LLM Text Generation

Claude AI models — intelligent assistants for analysis, writing, coding, and complex reasoning. Claude 3 Haiku (fast/cheap), Sonnet (balanced), and Opus (most capable). Pay-per-token.

Authentication

API Key API key from console.anthropic.com. Pass as x-api-key header. Also requires anthropic-version: 2023-06-01 header.

Sample Requests

POST Create a message

Generate a response with Claude Haiku.

https://api.anthropic.com/v1/messages

Hover any highlighted part to learn what it does

Headers — extra info sent with the request
x-api-key YOUR_KEY
Content-Type application/json
anthropic-version 2023-06-01
Request Body — data you're sending
{
  "model": "claude-haiku-4-5-20251001",
  "messages": [
    {
      "role": "user",
      "content": "Write a haiku about APIs."
    }
  ],
  "max_tokens": 256
}
curl -X POST "https://api.anthropic.com/v1/messages" \
  -H "x-api-key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"model":"claude-haiku-4-5-20251001","messages":[{"role":"user","content":"Write a haiku about APIs."}],"max_tokens":256}'
import requests
headers = {
    "x-api-key": "YOUR_KEY",
    "Content-Type": "application/json",
    "anthropic-version": "2023-06-01"
}
data = {
    "model": "claude-haiku-4-5-20251001",
    "messages": [
        {
            "role": "user",
            "content": "Write a haiku about APIs."
        }
    ],
    "max_tokens": 256
}
response = requests.post(
    "https://api.anthropic.com/v1/messages",
    headers=headers,
    json=data,
)
print(response.json())
const url = 'https://api.anthropic.com/v1/messages';

const response = await fetch(url, {
  method: 'POST',
  headers: {
    'x-api-key': 'YOUR_KEY',
    'Content-Type': 'application/json',
    'anthropic-version': '2023-06-01'
  },
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
  "model": "claude-haiku-4-5-20251001",
  "messages": [
    {
      "role": "user",
      "content": "Write a haiku about APIs."
    }
  ],
  "max_tokens": 256
}),
}); 
const data = await response.json();
console.log(data);
package main

import (
	"fmt"
	"io"
	"net/http"
	"bytes"
	"encoding/json"
)

func main() {
	targetURL := "https://api.anthropic.com/v1/messages"
	jsonData, _ := json.Marshal({"model":"claude-haiku-4-5-20251001","messages":[{"role":"user","content":"Write a haiku about APIs."}],"max_tokens":256})
	req, _ := http.NewRequest("POST", targetURL, bytes.NewBuffer(jsonData))
	req.Header.Set("x-api-key", "YOUR_KEY")
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("anthropic-version", "2023-06-01")
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{}
	resp, _ := client.Do(req)
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
require "net/http"
require "json"

uri = URI("https://api.anthropic.com/v1/messages")

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"

req = Net::HTTP::Post.new(uri)
req["x-api-key"] = "YOUR_KEY"
req["Content-Type"] = "application/json"
req["anthropic-version"] = "2023-06-01"
req["Content-Type"] = "application/json"
req.body = "{\"model\":\"claude-haiku-4-5-20251001\",\"messages\":[{\"role\":\"user\",\"content\":\"Write a haiku about APIs.\"}],\"max_tokens\":256}"

res = http.request(req)
puts JSON.parse(res.body)
<?php
$url = "https://api.anthropic.com/v1/messages";
$opts = ["http" => [
    "method" => "POST",
    "header" => implode("\r\n", [
        "x-api-key: YOUR_KEY",
        "Content-Type: application/json",
        "anthropic-version: 2023-06-01",
        "Content-Type: application/json"
    ]),
    "content" => json_encode({"model":"claude-haiku-4-5-20251001","messages":[{"role":"user","content":"Write a haiku about APIs."}],"max_tokens":256}),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));

Postman Setup Guide

Get Postman ↗
  1. Get an API key at console.anthropic.com
  2. Set x-api-key: YOUR_KEY header
  3. Set anthropic-version: 2023-06-01 header (required)
  4. POST to /v1/messages with model, max_tokens, and messages array
  5. Models (Jun 2026): claude-haiku-4-5-20251001 (fast), claude-sonnet-4-6 (balanced), claude-opus-4-8 (powerful)

Open documentation ↗