akashi_anthropic 0.3.0 copy "akashi_anthropic: ^0.3.0" to clipboard
akashi_anthropic: ^0.3.0 copied to clipboard

Anthropic (Claude) provider adapter for the Akashi agent framework: wraps anthropic_sdk_dart behind Akashi's LanguageModel contract, normalizing text/thinking/tool_use blocks.

example/akashi_anthropic_example.dart

// A tiny end-to-end example of the Anthropic adapter: a streaming agent that
// calls a typed tool. Run with `dart run example/akashi_anthropic_example.dart`
// (needs ANTHROPIC_API_KEY).
import 'dart:io';

import 'package:akashi/akashi.dart';
import 'package:akashi_anthropic/akashi_anthropic.dart';

Future<void> main() async {
  final apiKey = Platform.environment['ANTHROPIC_API_KEY'];
  if (apiKey == null) {
    stderr.writeln('Set ANTHROPIC_API_KEY to run this example.');
    exit(64);
  }

  final provider = AnthropicProvider(apiKey: apiKey);
  final agent = ToolLoopAgent<Object?>(
    model: provider.languageModel('claude-haiku-4-5-20251001'),
    tools: [
      tool<({String city}), Object?>(
        name: 'get_weather',
        description: 'Current weather for a city.',
        inputSchema: Schema.object<({String city})>(
          {'city': Schema.string()},
          required: ['city'],
          fromJson: (j) => (city: j['city']! as String),
        ),
        execute: (input, ctx) => 'It is 7°C and rainy in ${input.city}.',
      ),
    ],
  );

  await for (final event in agent.stream('What should I wear in Oslo today?')) {
    switch (event) {
      case TextDelta(:final text):
        stdout.write(text);
      case ToolResult(:final result):
        stdout.writeln('\n[tool ${result.toolName} -> ${result.output}]');
      case RunFinish():
        stdout.writeln();
      default:
        break;
    }
  }
}
0
likes
150
points
35
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Anthropic (Claude) provider adapter for the Akashi agent framework: wraps anthropic_sdk_dart behind Akashi's LanguageModel contract, normalizing text/thinking/tool_use blocks.

Repository (GitHub)
View/report issues

Topics

#ai #agents #llm #anthropic

License

MIT (license)

Dependencies

akashi, anthropic_sdk_dart

More

Packages that depend on akashi_anthropic