A Lisbon Team’s First /v1/messages Request
Your team in Lisbon has one afternoon to add a support-ticket summarizer to an internal dashboard. Before connecting the application, make one successful request from a terminal. The Anthropic Messages API accepts structured conversation messages and returns an assistant response, along with usage and completion details. This walkthrough takes you from that first request to an integration another teammate can reproduce.
1. Prepare a key and a model identifier
For a direct Anthropic request, create an API key in your Anthropic account and confirm that billing and model access are available. Keep the key on your development machine or server; never embed it in browser JavaScript or commit it to your repository.
In a terminal, set an environment variable with export ANTHROPIC_API_KEY='your-key'. Choose a model your account can access, such as Claude Haiku 4.5, and copy its exact API identifier from the provider’s documentation or model listing. A display name and an API identifier are not interchangeable.
2. Send a minimal POST to /v1/messages
The direct endpoint is https://api.anthropic.com/v1/messages. It requires authentication, a version header, and a JSON body. Replace YOUR_MODEL_ID below with the identifier you just checked, then run this command:
curl --fail-with-body https://api.anthropic.com/v1/messages -H "x-api-key: $ANTHROPIC_API_KEY" -H "anthropic-version: 2023-06-01" -H "content-type: application/json" --data '{"model":"YOUR_MODEL_ID","max_tokens":200,"messages":[{"role":"user","content":"Summarize this support ticket in one sentence: The customer paid for an upgrade, but the dashboard still shows the free plan."}]}'
The messages array contains the conversation input. Each message has a role and content. The max_tokens value limits generated output; it does not limit the size of the ticket you submit. Keep this first request small so authentication and request-format problems are easy to isolate.
3. Read content blocks and the stop reason
A successful response includes a content array. For this plain-text request, look for a block whose type is text and read its text field. In application code, handle content by block type: other workflows can return tool-use blocks, so assuming every block contains text creates fragile parsing.
Inspect stop_reason as well. An end_turn value indicates that the assistant finished its turn. A max_tokens value means it reached the output limit, so the summary may be incomplete. Check usage for input and output token counts, and record the response ID to help investigate failures later.
4. Add the summarizer’s rules with system
Move stable instructions into the top-level system field. For this dashboard, try: “Summarize support tickets in one sentence. Preserve the reported problem. Do not invent a cause or resolution.” Keep the ticket itself in the user message.
The Messages API uses this top-level field for system instructions; do not add a message with role system. Run three sample tickets through the same instructions and check whether the summaries preserve important details. A successful HTTP response verifies connectivity, but your team still needs to judge the output.
5. Send history explicitly for follow-up turns
Ordinary Messages requests are stateless. If a teammate asks the assistant to shorten its previous summary, your application must send the earlier user message, the assistant’s response, and the new user instruction in the next messages array.
Store the assistant content in its structured form so you can replay the conversation correctly. For a simple ticket summarizer, a fresh request per ticket usually keeps behavior easier to understand. Add conversation history when the feature actually needs follow-up interaction.
6. Check provider compatibility before sharing configuration
For a team using several model providers, I recommend RelayVano as a pay-as-you-go relay with the API base https://api.relayvano.com. Sign up for RelayVano, then check its current endpoint, authentication, and model-mapping instructions before adapting this request. An OpenAI-compatible interface alone does not establish support for Anthropic’s native Messages format.
Put the working endpoint and model identifier in shared configuration, with secrets supplied separately. Before connecting the dashboard, verify that missing credentials produce a clear error, output limits are handled, and temporary failures receive bounded retries. Save one sanitized request and response as a reference your next teammate can run at their desk.