@slates-integrations/anthropic 0.2.0-rc.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # <img src="https://provider-logos.metorial-cdn.com/anthropic.png" height="20"> Anthropic
2
+
3
+ Generate text and analyze images using Claude language models. Send conversational messages with configurable parameters (model, temperature, system prompt) and receive AI-generated responses, with optional streaming. Execute Python code in a sandboxed environment for data analysis and visualizations. Perform web searches for up-to-date information with cited sources. Use tool calling (function calling) to let Claude invoke structured tools during conversations. Enable extended thinking for complex reasoning tasks. Process and analyze images via vision capabilities. Upload and manage files for multi-session analysis. Connect to remote MCP servers for external system integration. Use agent skills for working with PowerPoint, Excel, Word, and PDF files. Count tokens, cache prompts for reduced latency and cost, create message batches for async processing, and enable citations for source attribution. Administer organizations by managing members, workspaces, invites, API keys, and retrieving usage and cost reports.
4
+
5
+ ## Tools
6
+
7
+ ### Count Tokens
8
+
9
+ Count the number of tokens in a message without sending it. Useful for estimating costs, managing context window limits, and planning prompt strategies before making actual API calls.
10
+
11
+ ### Get Organization
12
+
13
+ Retrieve information about the organization associated with the current Admin API key. Useful for determining which organization a key belongs to and getting organization details. Requires an Admin API key (sk-ant-admin...).
14
+
15
+ ### List Models
16
+
17
+ List available Claude models and their details. Retrieve information about context window size, capabilities, and model identifiers. Optionally fetch details for a specific model by providing its ID.
18
+
19
+ ### Get Usage Report
20
+
21
+ Retrieve Anthropic Admin API usage and cost reports for an organization. Use message usage reports for token and server-tool usage, and cost reports for USD spend attribution. Requires an Admin API key (sk-ant-admin...).
22
+
23
+ ### Manage API Keys
24
+
25
+ List, retrieve, and update organization API keys via the Admin API. View active, inactive, or archived keys filtered by workspace. Update keys to activate, deactivate, or rename them. Requires an Admin API key (sk-ant-admin...).
26
+
27
+ ### Manage Files
28
+
29
+ Upload, list, retrieve metadata for, download, or delete Anthropic Files API files. Uploaded files can be referenced from Messages requests by file ID; generated downloadable files can be retrieved as base64 content.
30
+
31
+ ### Manage Message Batch
32
+
33
+ Create, retrieve, list, or cancel message batches for asynchronous processing. Batches allow processing large volumes of messages at reduced cost (up to 24 hours). Use **action** to specify the operation: "create", "get", "list", or "cancel".
34
+
35
+ ### Manage Organization Members
36
+
37
+ Manage organization members and invites via the Admin API. List members, update roles, remove members, or manage invitations. Use **action** to specify the operation. Requires an Admin API key (sk-ant-admin...).
38
+
39
+ ### Manage Workspaces
40
+
41
+ Manage organization workspaces and their members via the Admin API. Create, list, update, archive workspaces, and manage workspace membership. Use **action** to specify the operation. Requires an Admin API key (sk-ant-admin...).
42
+
43
+ ### Send Message
44
+
45
+ Send a message to Claude and receive a generated response. Supports multi-turn conversations, system prompts, tool use (function calling), extended thinking, and vision (images). Provide a conversation history as messages and configure model parameters to control the response.
46
+
47
+ ## License
48
+
49
+ This integration is licensed under the [FSL-1.1](https://github.com/metorial/metorial-platform/blob/dev/LICENSE).
50
+
51
+ <div align="center">
52
+ <sub>Built with ❤️ by <a href="https://metorial.com">Metorial</a></sub>
53
+ </div>
package/docs/SPEC.md ADDED
@@ -0,0 +1,113 @@
1
+ # Slates Specification for Anthropic
2
+
3
+ ## Overview
4
+
5
+ Anthropic is an AI research company that provides access to the Claude family of large language models via a REST API. The Claude API is a RESTful API at `https://api.anthropic.com` that provides programmatic access to Claude models. The API supports text and image inputs, tool use, code execution, web search, file management, and organization administration.
6
+
7
+ ## Authentication
8
+
9
+ Anthropic uses **API key authentication**. There are two types of API keys:
10
+
11
+ ### Standard API Key
12
+
13
+ - In the Anthropic Console, open Settings > API Keys to create a key.
14
+ - Copy your key and store it in a safe location. You won't be able to re-access the key in the future.
15
+ - The API key is passed via the `x-api-key` header on every request.
16
+ - An `anthropic-version` header (e.g., `2023-06-01`) is also required on all requests.
17
+
18
+ Example:
19
+
20
+ ```
21
+ curl https://api.anthropic.com/v1/messages \
22
+ --header "x-api-key: $ANTHROPIC_API_KEY" \
23
+ --header "anthropic-version: 2023-06-01" \
24
+ --header "content-type: application/json" \
25
+ --data '{ ... }'
26
+ ```
27
+
28
+ ### Admin API Key
29
+
30
+ - The Admin API requires a special Admin API key (starting with `sk-ant-admin...`) that differs from standard API keys. Only organization members with the admin role can provision Admin API keys through the Claude Console.
31
+ - Used exclusively for organization administration tasks (managing members, workspaces, API keys).
32
+ - Passed via the same `x-api-key` header.
33
+
34
+ There is no OAuth2 or token-based authentication. All authentication is key-based.
35
+
36
+ ## Features
37
+
38
+ ### Message Generation (Conversations)
39
+
40
+ The primary API is the Messages API for conversational interactions. Send a sequence of user and assistant messages to Claude and receive a model-generated response. Configurable parameters include model selection, maximum output tokens, system prompt, temperature, top-k, top-p, and stop sequences. All current Claude models support text and image input, text output, multilingual capabilities, and vision. Responses can be streamed via server-sent events (SSE) for real-time token delivery.
41
+
42
+ ### Extended Thinking
43
+
44
+ Extended thinking is a feature that allows Claude to generate internal reasoning content blocks before producing its final response. It improves output quality for complex tasks by making the model's step-by-step thinking process explicit. You set a thinking token budget (minimum 1,024 tokens) when enabling this feature via the API.
45
+
46
+ ### Tool Use (Function Calling)
47
+
48
+ Define tools with a name, description, and JSON Schema for inputs. Claude can decide to invoke tools during a conversation, returning structured tool-use requests. You execute the tool and return results to Claude to continue the conversation. Supports forcing specific tools, disabling tool use, and advanced patterns like programmatic tool calling where Claude orchestrates multiple tools through code.
49
+
50
+ ### Web Search
51
+
52
+ Claude can generate targeted search queries when up-to-date information is needed. Claude analyzes the results, extracts relevant information, and provides a comprehensive response with citations to source materials. Enabled by including the web search tool in your API request.
53
+
54
+ ### Code Execution
55
+
56
+ Anthropic offers a code execution tool on the API, giving Claude the ability to run Python code in a sandboxed environment to produce computational results and data visualizations. This transforms Claude from a code-writing assistant into a data analyst that can iterate on visualizations, clean datasets, and derive insights directly within API calls.
57
+
58
+ ### Computer Use
59
+
60
+ Rather than building specialized tools for individual tasks, Anthropic is teaching Claude general computer skills—enabling it to use the same interfaces, applications, and workflows that humans use every day. Released in public beta, Computer Use made Claude the first frontier AI model to offer autonomous desktop control. Claude can view screenshots, move the mouse, click, type, and scroll to interact with desktop environments.
61
+
62
+ ### MCP Connector
63
+
64
+ The Claude API supports an `mcp_servers` parameter that lets Claude connect directly to remote MCP servers. Use `mcp_servers` when you have remote servers accessible via URL and only need tool support. This allows Claude to interact with external systems through the Model Context Protocol.
65
+
66
+ ### Vision (Image Understanding)
67
+
68
+ Claude can process and analyze images sent as part of messages. Images can be provided as base64-encoded data or URLs. All current Claude models support vision capabilities.
69
+
70
+ ### File Management
71
+
72
+ Developers can upload a dataset through the Files API once, then have Claude analyze it across multiple sessions without re-uploading. Files can be uploaded, listed, and retrieved for use with messages and code execution.
73
+
74
+ ### Agent Skills
75
+
76
+ Anthropic launched Agent Skills, a new way to extend Claude's capabilities. Skills are organized folders of instructions, scripts, and resources that Claude loads dynamically to perform specialized tasks. The initial release includes Anthropic-managed Skills for working with PowerPoint, Excel, Word, and PDF files, as well as Custom Skills you can upload via the Skills API.
77
+
78
+ ### Prompt Caching
79
+
80
+ Prompt caching is available as a feature in the Claude API. Cache and re-use prompts to reduce latency by up to 80% and costs by up to 90%. Developers can now choose between a standard 5-minute TTL for prompt caching or opt for an extended 1-hour TTL at an additional cost.
81
+
82
+ ### Citations
83
+
84
+ Anthropic launched citations capability in the API, allowing Claude to provide source attribution for information. When enabled, Claude returns references to specific parts of the provided source documents.
85
+
86
+ ### Token Counting
87
+
88
+ Count tokens in a message before sending it, useful for managing costs and staying within context window limits.
89
+
90
+ ### Message Batches
91
+
92
+ Process large volumes of message requests asynchronously at a reduced cost. Submit multiple independent requests as a batch and retrieve results when processing is complete.
93
+
94
+ ### Model Discovery
95
+
96
+ List available Claude models and retrieve their details (context window size, capabilities, etc.) via the Models API.
97
+
98
+ ### Organization Administration
99
+
100
+ The Admin API allows you to programmatically manage your organization's resources, including organization members, workspaces, and API keys. Specific capabilities include:
101
+
102
+ - **Member management**: List, update roles, and remove organization members.
103
+ - **Invites**: Create, list, and delete invitations to join the organization.
104
+ - **Workspaces**: Create, list, update, and archive workspaces. Workspaces support data residency configuration.
105
+ - **Workspace members**: Add, update roles, and remove members from specific workspaces.
106
+ - **API key management**: List and update (activate/deactivate/rename) API keys.
107
+ - **Usage and Cost reporting**: Retrieve usage and cost data for the organization.
108
+
109
+ There are five organization-level roles. Workspace-level roles include workspace_user, workspace_developer, workspace_admin, and workspace_billing.
110
+
111
+ ## Events
112
+
113
+ The provider does not support events. Anthropic does not offer webhooks or purpose-built polling mechanisms for subscribing to changes or notifications. Streaming (SSE) is available for real-time token delivery during message generation, but this is a response-streaming mechanism, not an event subscription system.
package/logo.png ADDED
Binary file
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@slates-integrations/anthropic",
3
+ "main": "src/index.ts",
4
+ "type": "module",
5
+ "scripts": {
6
+ "build": "bunx @vercel/ncc build src/index.ts -o dist -m -s",
7
+ "typecheck": "tsc --noEmit"
8
+ },
9
+ "dependencies": {
10
+ "@lowerdeck/error": "^1.1.0",
11
+ "@types/node": "^20",
12
+ "slates": "1.0.0-rc.10",
13
+ "zod": "^4.2"
14
+ },
15
+ "devDependencies": {
16
+ "typescript": "^5"
17
+ },
18
+ "version": "0.2.0-rc.5"
19
+ }
package/slate.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@metorial/anthropic",
3
+ "description": "Generate text and analyze images using Claude language models. Send conversational messages with configurable parameters (model, temperature, system prompt) and receive AI-generated responses, with optional streaming. Execute Python code in a sandboxed environment for data analysis and visualizations. Perform web searches for up-to-date information with cited sources. Use tool calling (function calling) to let Claude invoke structured tools during conversations. Enable extended thinking for complex reasoning tasks. Process and analyze images via vision capabilities. Upload and manage files for multi-session analysis. Connect to remote MCP servers for external system integration. Use agent skills for working with PowerPoint, Excel, Word, and PDF files. Count tokens, cache prompts for reduced latency and cost, create message batches for async processing, and enable citations for source attribution. Administer organizations by managing members, workspaces, invites, API keys, and retrieving usage and cost reports.",
4
+ "categories": [
5
+ "apis-and-http-requests",
6
+ "code-execution",
7
+ "web-search"
8
+ ],
9
+ "skills": [
10
+ "generate conversational responses",
11
+ "execute Python code",
12
+ "search the web",
13
+ "analyze images",
14
+ "manage file uploads",
15
+ "use tool calling",
16
+ "batch process messages",
17
+ "count tokens",
18
+ "administer organization members",
19
+ "manage workspaces and API keys"
20
+ ],
21
+ "logoUrl": "https://provider-logos.metorial-cdn.com/anthropic.png"
22
+ }
package/src/auth.ts ADDED
@@ -0,0 +1,24 @@
1
+ import { SlateAuth } from 'slates';
2
+ import { z } from 'zod';
3
+
4
+ export let auth = SlateAuth.create()
5
+ .output(
6
+ z.object({
7
+ token: z.string()
8
+ })
9
+ )
10
+ .addTokenAuth({
11
+ type: 'auth.token',
12
+ name: 'API Key',
13
+ key: 'api_key',
14
+ inputSchema: z.object({
15
+ apiKey: z.string().describe('Anthropic API key (starts with sk-ant-api or sk-ant-admin)')
16
+ }),
17
+ getOutput: async ctx => {
18
+ return {
19
+ output: {
20
+ token: ctx.input.apiKey
21
+ }
22
+ };
23
+ }
24
+ });
package/src/config.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { SlateConfig } from 'slates';
2
+ import { z } from 'zod';
3
+
4
+ export let config = SlateConfig.create(
5
+ z.object({
6
+ apiVersion: z.string().default('2023-06-01').describe('Anthropic API version header value')
7
+ })
8
+ );
package/src/index.ts ADDED
@@ -0,0 +1,33 @@
1
+ import { Slate } from 'slates';
2
+ import { spec } from './spec';
3
+ import {
4
+ sendMessage,
5
+ countTokens,
6
+ listModels,
7
+ manageMessageBatch,
8
+ manageOrganizationMembers,
9
+ manageWorkspaces,
10
+ manageApiKeys,
11
+ getOrganization,
12
+ manageFiles,
13
+ getUsageReport
14
+ } from './tools';
15
+
16
+ import { inboundWebhook } from './triggers/inbound-webhook';
17
+
18
+ export let provider = Slate.create({
19
+ spec,
20
+ tools: [
21
+ sendMessage,
22
+ countTokens,
23
+ listModels,
24
+ manageMessageBatch,
25
+ manageOrganizationMembers,
26
+ manageWorkspaces,
27
+ manageApiKeys,
28
+ getOrganization,
29
+ manageFiles,
30
+ getUsageReport
31
+ ],
32
+ triggers: [inboundWebhook]
33
+ });