Anthropic Claude

Anthropic is an AI safety company that builds reliable, interpretable, and steerable AI systems. Their flagship model family is Claude, which excels at thoughtful dialogue, content creation, complex reasoning, coding, and more.

The sgcWebSockets library provides a Delphi component TsgcHTTP_API_Anthropic to interact with the Anthropic Claude API.

Anthropic API

The Anthropic API provides access to Claude models for building AI-powered applications. The API supports text generation, vision (image understanding), tool use (function calling), extended thinking, document/PDF processing, prompt caching, citations, web search, streaming, token counting, and message batches.

Features

Configuration

The Anthropic API uses API keys for authentication. Visit your API Keys page in the Anthropic Console to retrieve the API key you'll use in your requests.

Remember that your API key is a secret! Do not share it with others or expose it in any client-side code.

This API Key must be configured in the AnthropicOptions.ApiKey property of the component. The AnthropicOptions.AnthropicVersion property specifies the API version (default: 2023-06-01).


Anthropic := TsgcHTTP_API_Anthropic.Create(nil);
Anthropic.AnthropicOptions.ApiKey := 'YOUR_API_KEY';

Messages

Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation.

Vision

Claude can understand images passed as base64-encoded content blocks within messages.

Tool Use

Claude can use tools (function calling) to interact with external systems. You define tools with their names, descriptions, and input schemas, and Claude will generate tool_use content blocks when it wants to call a tool.

Models

List and describe the available Claude models.

Extended Thinking

Extended thinking enables Claude to reason step-by-step before responding, improving quality for complex tasks like math, coding, and analysis.

Documents

Claude can process PDF documents and text files sent as content blocks. Supports base64, text, and URL source types.

Prompt Caching

Cache frequently used context (system prompts, content blocks, tool definitions) between API calls to reduce costs by up to 90% on cache reads.

Citations

When documents are sent with citations enabled, Claude includes source references in its response. Citation types include char_location (text), page_location (PDF), content_block_location (custom content), and web_search_result_location (web search).

Web Search

Claude can search the web for real-time information using the built-in web_search tool. Other built-in tools include code_execution and computer use.

Token Counting

Count the number of tokens in a message before sending it.

Message Batches

The Message Batches API allows you to process large volumes of messages asynchronously.

Structured Outputs

Force Claude to return valid JSON conforming to a provided JSON Schema. Combine with the Effort parameter to control output quality vs. cost.

Files API

Upload, list, retrieve, download, and delete files. Uploaded files can be referenced in messages using document content blocks with file source type. Requires beta header files-api-2025-04-14.

Request Parameters

Additional request parameters available on the Messages API.

MCP Connector

Connect Claude to external MCP (Model Context Protocol) servers to access third-party tools. Requires beta header mcp-client-2025-11-20.