Everyone says you need to be a "developer" to use an API. That's cargo cult nonsense. I've seen more production fires lit by "senior engineers" with a dozen YAML files than a sysadmin with a simple curl command. The API is often the simpler, more reliable interface once you get past the gatekeeping.
Forget the "quick start" guides that assume you have Node.js and npm installed. You just need three things: your Anthropic API key, the Claude model name (like `claude-3-5-sonnet-20241022`), and a way to send HTTP requests. We'll use `curl` because it's on every Mac/Linux box and available for Windows. No package managers, no virtual environments, no dependency hell.
First, set your API key as an environment variable. Do this in your terminal. It's safer than pasting it into every command.
```bash
export ANTHROPIC_API_KEY='your-key-here'
```
Now, here's the bare minimum request. Save this to a file called `request.json`. This is your configuration, and it's easier to debug than a 20-line Python script.
```json
{
"model": "claude-3-5-sonnet-20241022",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Explain how an API works, but use a metaphor about postal mail."
}
]
}
```
Then send it. This is the single command that does the work.
```bash
curl https://api.anthropic.com/v1/messages
-H "x-api-key: $ANTHROPIC_API_KEY"
-H "anthropic-version: 2023-06-01"
-H "content-type: application/json"
-d @request.json
```
You'll get a JSON response. Use `jq` to filter it if you want, or just eyeball it. The point is you're now making calls. You can change the prompt in the JSON file and run the curl command again. No boilerplate, no middleware, no abstractions. This is how I prototype automations before anyone writes a line of "real" code.
The moment it gets more complex, *then* you might write a script. But you'd be surprised how far you can get by templating that JSON file and looping over it with a shell script. The API is the clean interface. The rest is just tooling, and you should choose the simplest tool that doesn't create more problems than it solves.