Skip to main content

Llama Search Python SDK

The official Python SDK for the Llama Search AI Platform. This SDK provides a simple, intuitive interface for integrating AI-powered web search capabilities into your applications.

Installation

pip install llama-search

Quick Start

First, set your API key as an environment variable:

export LLAMA_SEARCH_API_KEY="your_api_key_here"

Or create a .env file:

LLAMA_SEARCH_API_KEY=your_api_key_here
from llama_search import AsyncLlamaSearch

async def main():
    # API key loaded from LLAMA_SEARCH_API_KEY environment variable
    async with AsyncLlamaSearch() as client:
        # Perform a web search
        result = await client.web_search(
            query="Tesla Model 3 battery specifications",
            search_depth="standard"
        )

        print(f"Found {len(result.sources)} sources")
        for source in result.sources:
            print(f"- {source.url}: {source.content[:100]}...")

        # Check account usage
        stats = await client.get_usage_stats()
        print(f"Credits remaining: {stats.credits_remaining}")
        print(f"Total searches: {stats.total_searches}")

import asyncio
asyncio.run(main())

Sync Usage

from llama_search import LlamaSearch

with LlamaSearch() as client:
    # Perform a web search
    result = client.web_search(
        query="Tesla Model 3 battery specifications",
        search_depth="standard"
    )

    print(f"Found {len(result.sources)} sources")
    for source in result.sources:
        print(f"- {source.url}: {source.content[:100]}...")

    # Check account usage
    stats = client.get_usage_stats()
    print(f"Credits remaining: {stats.credits_remaining}")
    print(f"Total searches: {stats.total_searches}")

API Reference

Core Search Methods

web_search(query, search_depth="standard", domain="", with_full_content=False)

Perform intelligent web search using AI.

Parameters:

  • query (str): The search query to execute
  • search_depth (str): Search depth level affecting cost and quality
    • "basic": 5 credits, 2 tool calls, low context
    • "standard": 8 credits, 3 tool calls, medium context (default)
    • "extensive": 15 credits, 5 tool calls, high context
  • domain (str): Optional domain filter (e.g., "reddit.com")
  • with_full_content (bool): Whether to fetch full content from URLs

Returns: WebSearchResult containing sources and metadata

result = await client.web_search("Python asyncio best practices", search_depth="extensive")
print(f"Credits consumed: {result.credits_consumed}")

get_search_types()

Get available search types and their costs.

Returns: SearchTypesResponse containing available search types

types = await client.get_search_types()
for search_type in types.search_types:
    print(f"{search_type.name}: {search_type.credits} credits")

Account Management

get_usage_stats()

Get current usage statistics for your account.

Returns: UsageStats containing search counts, credits used/remaining, monthly usage

stats = await client.get_usage_stats()
print(f"Credits remaining: {stats.credits_remaining}")
print(f"Searches this month: {stats.searches_this_month}")
print(f"Total searches: {stats.total_searches}")

get_search_history(limit=10)

Get your recent search history.

Parameters:

  • limit (int): Maximum number of searches to return (1-100, default: 10)

Returns: SearchHistory containing list of recent searches

history = await client.get_search_history(limit=20)
for search in history.searches:
    print(f"{search.created_at}: {search.query} ({search.credits_consumed} credits)")

Requirements

  • Python 3.10+
  • httpx >= 0.24.0
  • pydantic >= 2.0.0

Development

Running Tests

# Install development dependencies
pip install -e ".[dev]"

# Run tests
make test

# Run tests with coverage
pytest --cov=llama_search

Code Quality

# Format code
make format

# Lint code
make lint

# Type checking
make typecheck

License

MIT License - see LICENSE file for details.

Support

Metadata

Release files for llama-search 0.3.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llama-search 0.3.4
File Size Uploaded
llama_search-0.3.4.tar.gz 22.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llama-search 0.3.4
File Interpreter ABI Platform
llama_search-0.3.4-py3-none-any.whl Python 3 none any Details

Total release size: 38.9 kB

Release files / llama_search-0.3.4.tar.gz

Download URL llama_search-0.3.4.tar.gz
Size 22.0 kB
Tags Source
SHA-256 checksum
How to use checksums
85967a32d85eaec6bee1207bd063b910ec0ecd1b10a852b788856928cb4e0722
BLAKE2b-256 checksum
How to use checksums
a93a47c03e002804aa68b310dc11e6f9cd1869911b9f2e524f2cde8ad341b8a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / llama_search-0.3.4-py3-none-any.whl

Download URL llama_search-0.3.4-py3-none-any.whl
Size 16.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b8bcf85f248110ad0398152366d1452949805057da36e3cf3fac75ed04dffff6
BLAKE2b-256 checksum
How to use checksums
456437b23d258039ccd9354179b388d5ccb2e61ef7e5b1e95b31c6a9fbce852e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

0.3.4 This release

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page