UNPKG

@genkit-ai/anthropic

Version:

Genkit AI framework plugin for Anthropic APIs.

67 lines (63 loc) 2.5 kB
import { GenkitPluginV2 } from 'genkit/plugin'; import { ModelReference, z, Part } from 'genkit'; import { KnownClaudeModels, ClaudeModelName } from './models.js'; import { PluginOptions, ClaudeConfig, AnthropicConfigSchemaType, AnthropicDocumentOptions } from './types.js'; export { AnthropicCitation } from './types.js'; export { cacheControl } from './utils.js'; export { CacheControlEphemeral as AnthropicCacheControl } from '@anthropic-ai/sdk/resources/messages'; import 'genkit/model'; import '@anthropic-ai/sdk'; /** * Copyright 2024 Bloom Labs Inc * Copyright 2025 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ type AnthropicPlugin = { (pluginOptions?: PluginOptions): GenkitPluginV2; model(name: KnownClaudeModels | (ClaudeModelName & {}), config?: ClaudeConfig): ModelReference<AnthropicConfigSchemaType>; model(name: string, config?: any): ModelReference<z.ZodTypeAny>; }; /** * Anthropic AI plugin for Genkit. * Includes Claude models (3, 3.5, and 4 series). */ declare const anthropic: AnthropicPlugin; /** * Creates a custom part representing an Anthropic document with optional citations support. * * Use this to provide documents to Claude that can be cited in responses. * Citations must be enabled on all or none of the documents in a request. * * @example * ```ts * import { anthropic, anthropicDocument } from '@genkit-ai/anthropic'; * * const { text } = await ai.generate({ * model: anthropic.model('claude-sonnet-4-5'), * messages: [{ * role: 'user', * content: [ * anthropicDocument({ * source: { type: 'text', data: 'The grass is green. The sky is blue.' }, * title: 'Nature Facts', * citations: { enabled: true } * }), * { text: 'What color is the grass?' } * ] * }] * }); * ``` */ declare function anthropicDocument(options: AnthropicDocumentOptions): Part; export { type AnthropicPlugin, anthropic, anthropicDocument, anthropic as default };