/**
* 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.
*/
import { anthropic } from '@genkit-ai/anthropic';
import { genkit } from 'genkit';
const ai = genkit({
plugins: [
// Default all flows in this sample to the beta surface
anthropic({
apiVersion: 'beta',
cacheSystemPrompt: true,
apiKey: process.env.ANTHROPIC_API_KEY,
}),
],
});
const betaOpus45 = anthropic.model('claude-opus-4-5', { apiVersion: 'beta' });
ai.defineFlow('anthropic-beta-low-effort', async () => {
const { text } = await ai.generate({
model: betaOpus45,
prompt: `Create me a Mathematics class using the programming language Python.`,
config: {
maxOutputTokens: 4096,
temperature: 0.6,
output_config: {
effort: 'low',
},
},
});
return text;
});
ai.defineFlow('anthropic-beta-medium-effort', async () => {
const { text } = await ai.generate({
model: betaOpus45,
prompt: `Create me a Mathematics class using the programming language Python.`,
config: {
maxOutputTokens: 4096,
temperature: 0.6,
output_config: {
effort: 'medium',
},
},
});
return text;
});
ai.defineFlow('anthropic-beta-high-effort', async () => {
const { text } = await ai.generate({
model: betaOpus45,
prompt: `Create me a Mathematics class using the programming language Python.`,
config: {
maxOutputTokens: 4096,
temperature: 0.6,
output_config: {
effort: 'high',
},
},
});
return text;
});