datacircle / anthropic-tools
Find the best GTM APIs. Four tools for the tool runner of the Anthropic PHP SDK. The tools call Datacircle's public API. You need no API key.
Package info
github.com/waynehamadi/anthropic-php-datacircle
pkg:composer/datacircle/anthropic-tools
Requires
- php: ^8.1
- ext-json: *
- anthropic-ai/sdk: ^0.7 || ^1.0
- php-http/discovery: ^1
- psr/http-client: ^1
- psr/http-factory: ^1
- psr/http-message: ^1 || ^2
Requires (Dev)
- guzzlehttp/guzzle: ^7.9
- phpunit/phpunit: ^10.5 || ^11.5 || ^12.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Find the best GTM APIs. We benchmark all the GTM APIs and we put the results on our website.
Our website: https://datacircle.dev
This package gives the Anthropic PHP SDK four tools that call Datacircle's open API, https://api.datacircle.dev/v1. They run in the SDK's tool runner, $client->beta->messages->toolRunner(). You need no key and no account.
| Tool | What the tool gives | Call |
|---|---|---|
datacircle_list_apis |
Every GTM API on Datacircle, with the API's slug, number of plans, number of providers and best plan | GET /apis |
datacircle_best_plans |
One API's plans, sorted by score out of 100, best first. Each plan comes with a rank and a price per 1,000 calls | GET /apis/{slug}/best |
datacircle_search_plans |
Plans that match a provider or plan name, on all APIs or on one API. You can sort them by score, provider or price | GET /plans |
datacircle_provider |
The APIs a provider sells, and the provider's rank on each API | GET /providers/{slug} |
Install
composer require datacircle/anthropic-tools
The package needs PHP 8.1 or later and anthropic-ai/sdk 0.7.0 or later. Version 0.7.0 is the first with the tool runner. The tools send their calls through your app's PSR-18 HTTP client, such as Guzzle. The SDK needs a PSR-18 HTTP client too.
Use the tools
Give the tools to the tool runner:
use Anthropic\Client; use Datacircle\Anthropic\Datacircle; $client = new Client(apiKey: getenv('ANTHROPIC_API_KEY')); $message = $client->beta->messages->toolRunner( maxTokens: 16000, messages: [['role' => 'user', 'content' => 'Who are the 3 best providers for the email-finder API?']], model: 'claude-opus-5-5', tools: Datacircle::tools(), )->runUntilDone(); foreach ($message->content as $block) { if ($block->type === 'text') { echo $block->text, "\n"; } }
Loop over the runner with foreach to get each message of the run. You can put the tools in one list with your own: tools: [...Datacircle::tools(), $myTool]. You can also pass the tools to addTools() or to a message thread's toolRunner(). To leave a tool out, filter the list by name:
$tools = array_values(array_filter(Datacircle::tools(), fn ($tool) => $tool->name() !== 'datacircle_provider'));
Make each call yourself
You can make each call without a model. You get the tool's answer as an array:
use Datacircle\Anthropic\Datacircle; $answer = Datacircle::bestPlans(['slug' => 'email-finder', 'limit' => 3]); print_r($answer['plans']);
The other calls are Datacircle::listApis(), Datacircle::searchPlans() and Datacircle::provider().
What the model reads
Each tool gives the model a JSON object as text. Each plan comes with a rank, provider, plan, score, price per 1,000 (perThousand, in dollars) and a page on datacircle.dev. That page lists every field.
For an unknown slug, the tool result is an error (is_error) with the API's message. If the input does not fit the schema, the error names each wrong argument. If the network fails, the tool result is an error with the network error's message. The model can then call the tool again and keep going. A call without a model gives the API's message as ['error' => '...'].
Pass new \Datacircle\Anthropic\Client(http: $httpClient) to Datacircle::tools() to send the calls through another PSR-18 client. Use this to add a proxy or a timeout. Each call without a model takes the same Client as a second argument.
Network
Each tool call sends HTTPS GET requests to https://api.datacircle.dev/v1 and nowhere else. Most calls send one request. datacircle_search_plans sends up to three when the first search finds nothing. The requests hold only the tool's own arguments: no key and nothing from your chats. The API takes up to 60 calls a minute from one IP address. The tool waits once, for a minute at most, when the API says to wait. The package stores nothing.
Links
- Datacircle: https://datacircle.dev
- The API: https://datacircle.dev/api
- The API's spec: https://api.datacircle.dev/v1/openapi.json
- What each key means: https://datacircle.dev/fields
MIT license.