Metadata-Version: 2.5
Name: litellm-datacircle
Version: 0.1.0
Summary: LiteLLM tools for the Datacircle API: find the best GTM APIs
Project-URL: Homepage, https://datacircle.dev
Project-URL: Documentation, https://api.datacircle.dev/v1/openapi.json
Project-URL: Repository, https://github.com/waynehamadi/litellm-datacircle
License-Expression: MIT
License-File: LICENSE
Keywords: api,api-pricing,b2b-data,datacircle,function-calling,gtm,litellm,llm,tool-calling,tools
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# litellm-datacircle

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 [LiteLLM](https://github.com/BerriAI/litellm) four tools that call Datacircle's open API, https://api.datacircle.dev/v1. You pass the four tools to `litellm.completion()`, on any provider LiteLLM supports. The package then runs each tool call the model returns. 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

```bash
pip install litellm-datacircle
```

litellm-datacircle works with any version of `litellm`, on Python 3.9 and later. The package does not import `litellm`.

## Use the tools with run_tool_loop

LiteLLM 1.106 and later can run the whole tool loop. Pass our `execute_tool` function as the `execute_tool` argument:

```python
import litellm
from litellm_datacircle import datacircle_tools, execute_tool

answer = litellm.run_tool_loop(
    model="anthropic/claude-haiku-5-5",
    messages=[{"role": "user", "content": "Who are the 3 best providers for the email-finder API?"}],
    tools=datacircle_tools(),
    execute_tool=execute_tool,
)
print(answer)
```

With `litellm.arun_tool_loop`, use `aexecute_tool`.

## Use the tools in your own loop

Pass the tools to `litellm.completion()`. If the model calls a tool, `call_all()` gives you the tool messages to send back:

```python
import litellm
from litellm_datacircle import call_all, datacircle_tools

messages = [{"role": "user", "content": "Who are the 3 best providers for the email-finder API?"}]
message = litellm.completion(model="openai/gpt-5-mini", messages=messages, tools=datacircle_tools()).choices[0].message

while message.tool_calls:
    messages.append(message)
    messages.extend(call_all(message))
    message = litellm.completion(model="openai/gpt-5-mini", messages=messages, tools=datacircle_tools()).choices[0].message

print(message.content)
```

Each tool is an OpenAI-format tool definition. LiteLLM turns each tool into the provider's own format. Each tool message has `role: "tool"`, the call's id in `tool_call_id`, and the answer as JSON text in `content`.

With `stream=True`, build the reply with `litellm.stream_chunk_builder(chunks, messages=messages)`. Then pass the reply's message to `call_all()`. With `litellm.acompletion()`, use `await acall_all(...)`. `acall_all()` runs the calls at the same time. Your event loop keeps running.

## Use the Datacircle tools beside your own tools

You can put the Datacircle tools in the same list as yours: `tools=[*datacircle_tools(), my_tool]`.

With `run_tool_loop`, `executor()` runs the Datacircle tools and hands every other call to your own function:

```python
answer = litellm.run_tool_loop(
    model="anthropic/claude-haiku-5-5",
    messages=messages,
    tools=[*datacircle_tools(), my_tool],
    execute_tool=executor(my_execute_tool),
)
```

With `arun_tool_loop`, use `aexecutor(my_async_execute_tool)`.

In your own loop, `call()` runs one tool call. For your own tools, `call()` returns `None`. Your code then runs the tool itself:

```python
from litellm_datacircle import call

for tool_call in message.tool_calls or []:
    messages.append(call(tool_call) or my_execute_tool(tool_call))
```

To give the model only some of the tools, list their names: `datacircle_tools(["datacircle_best_plans"])`.

## Use the tools with litellm.responses

`responses_tools()` gives our four tools in the Responses API's format. `call_outputs()` gives the `function_call_output` items to send back:

```python
import litellm
from litellm_datacircle import call_outputs, responses_tools

given = [{"role": "user", "content": "Who are the 3 best providers for the email-finder API?"}]
response = litellm.responses(model="anthropic/claude-haiku-5-5", input=given, tools=responses_tools())

while any(item.type == "function_call" for item in response.output):
    given += [item.model_dump(exclude_none=True) for item in response.output if item.type == "function_call"]
    given += call_outputs(response)
    response = litellm.responses(model="anthropic/claude-haiku-5-5", input=given, tools=responses_tools())

print(response.output[-1].content[0].text)
```

`call_output()` takes one item. `call_output()` returns `None` for a call to one of your own tools. With `litellm.aresponses()`, use `await acall_outputs(...)`.

## Call a tool yourself

You can call each tool without a model. You get the JSON text of the tool's answer:

```python
import json

from litellm_datacircle import run

answer = json.loads(run("datacircle_best_plans", {"slug": "email-finder", "limit": 3}))
print(answer["plans"])
```

## 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.

You can give a provider's name in place of a slug. The tool turns `Bright Data` into `bright-data`.

The tool returns `{"error": "..."}` with the API's message when the API gives no data, such as for an unknown slug. The error for an unknown API slug lists every valid slug. The tool checks each number from the model first. For a number out of range, the tool returns `{"error": "..."}` and makes no API call. If the network fails, the tool returns `{"error": "..."}` with the network error's message. The model can then call the tool again.

## Network

Each tool call makes one HTTPS GET request to https://api.datacircle.dev/v1 and nothing else. The request holds 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 API can ask the tool to wait. The tool then waits once, for a minute at most. Each call uses only Python's standard library. Nothing goes to disk.

## Links

- Datacircle: https://datacircle.dev
- The API: https://datacircle.dev/api
- The API's spec: https://api.datacircle.dev/v1/openapi.json
- Every field of a plan: https://datacircle.dev/fields

MIT license.
