Batrachian Toad

0.6.15 · active · verified Fri Apr 17

Batrachian Toad provides a unified Pythonic interface for interacting with various AI models directly from your terminal. It abstracts away the complexities of different AI providers (OpenAI, Anthropic, Google Gemini, etc.) into a simple API. The current version is 0.6.15, and as a pre-1.0 library, it is under active development with frequent releases.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates basic chat and image generation using the `Toad` class. It expects API keys like `OPENAI_API_KEY` to be set as environment variables. Without valid API keys, the actual AI calls will fail, though the Python code itself will execute up to the point of API interaction. Python 3.14 or newer is required.

import os
from batrachian_toad import Toad

# IMPORTANT: Set your API key as an environment variable, e.g.,
# export OPENAI_API_KEY="sk-your-openai-key"
# export ANTHROPIC_API_KEY="sk-your-anthropic-key"
# If not set, API calls will likely fail.

print("Attempting to use Toad for AI interactions...")

try:
    # Chat example (uses OpenAI by default)
    print("\n--- Chat Example ---")
    chat_response = Toad.chat("Tell me a short, inspiring quote.")
    print(f"Toad Chat: {chat_response.content}")

    # Image generation example (requires a provider like DALL-E, and a valid API key)
    # This may fail if the default provider doesn't support image generation or key is invalid.
    print("\n--- Image Generation Example ---")
    image_url = Toad.generate_image("A futuristic city at sunset in an anime style.")
    print(f"Toad Image URL: {image_url}")

    # Example of changing provider (uncomment and set ANTHROPIC_API_KEY to test)
    # Toad.set_default_provider("anthropic")
    # print("\n--- Summarization Example (using Anthropic if configured) ---")
    # summary_response = Toad.summarize("Long text to summarize...", model="claude-3-haiku-20240307")
    # print(f"Toad Summary: {summary_response.content}")

except Exception as e:
    print(f"\nAn error occurred during quickstart execution: {e}")
    print("Please ensure Python >=3.14 is installed and relevant API keys (e.g., OPENAI_API_KEY) are set in your environment.")

view raw JSON →