AI-Anthropic
view release on metacpan or search on metacpan
MANIFEST.SKIP view on Meta::CPAN
\.orig$
# OS files
\.DS_Store$
Thumbs\.db$
# IDE
\.vscode/
\.idea/
# Test/dev files
^\.prove$
^cover_db/
"requires" : {
"Carp" : "0",
"HTTP::Tiny" : "0.070",
"JSON::PP" : "2.0",
"MIME::Base64" : "0",
"perl" : "5.010"
}
},
"test" : {
"requires" : {
"Test::More" : "0.88"
}
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"web" : "https://github.com/yourusername/AI-Anthropic/issues"
},
"repository" : {
"type" : "git",
---
abstract: 'Perl interface to Anthropic Claude API'
author:
- 'Your Name <your@email.com>'
build_requires:
ExtUtils::MakeMaker: '0'
Test::More: '0.88'
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 7.76, CPAN::Meta::Converter version 2.150010'
keywords:
- anthropic
- claude
- ai
- llm
- api
Makefile.PL view on Meta::CPAN
MIN_PERL_VERSION => '5.010',
PREREQ_PM => {
'HTTP::Tiny' => '0.070',
'JSON::PP' => '2.0',
'MIME::Base64' => '0',
'Carp' => '0',
},
TEST_REQUIRES => {
'Test::More' => '0.88',
},
META_MERGE => {
'meta-spec' => { version => 2 },
resources => {
repository => {
type => 'git',
url => 'https://github.com/yourusername/AI-Anthropic.git',
web => 'https://github.com/yourusername/AI-Anthropic',
},
t/01-basic.t view on Meta::CPAN
#!/usr/bin/perl
use strict;
use warnings;
use Test::More;
# Test loading
use_ok('AI::Anthropic');
# Test object creation without API key (should fail gracefully later)
{
local $ENV{ANTHROPIC_API_KEY};
eval {
my $claude = AI::Anthropic->new();
};
like($@, qr/API key required/, 'Dies without API key');
}
# Test object creation with API key
{
my $claude = AI::Anthropic->new(api_key => 'test-key-123');
isa_ok($claude, 'AI::Anthropic');
}
# Test models list
{
my $claude = AI::Anthropic->new(api_key => 'test');
my @models = $claude->models;
ok(@models > 0, 'models() returns list');
ok(grep { /claude/ } @models, 'models contain claude');
}
# Test response object
{
my $response = AI::Anthropic::Response->new(
text => 'Hello!',
model => 'claude-sonnet-4-20250514',
stop_reason => 'end_turn',
usage => { input_tokens => 10, output_tokens => 5 },
);
is($response->text, 'Hello!', 'Response text');
is($response->model, 'claude-sonnet-4-20250514', 'Response model');
is($response->input_tokens, 10, 'Input tokens');
is($response->output_tokens, 5, 'Output tokens');
is($response->total_tokens, 15, 'Total tokens');
# Test stringification
is("$response", 'Hello!', 'Response stringifies to text');
}
done_testing();
( run in 0.435 second using v1.01-cache-2.11-cpan-9ff20fc0ed8 )