Skip to main content

IronLabs Python SDK — intelligent LLM routing

Project description

API vs SDK

  • Client side LLM invocation.
    • Our API endpoint of model-router, only recommends the model to use.
    • The sdk invokes the "recommended model" for the given prompt, gets the response back.

SDK also provides the following features which API endpoint doesn't via a common interface.

Features:
  • Model routing functionality using the IronaAI API endpoints
  • [] Support for async & sync requests of LLM-invocation.
  • Function calling,
  • Tool binding using LiteLLM's function calling capabilities
  • Error handling and retries
  • Support for streaming,
  • and JSON mode (i.e. structured output)
  • [] Detailed latency tracking and reporting - TBD
  • [] Creation of preference IDs - TBD
  • Retry logic (invocation or model-router)
  • Unified Interface
  • Tool binding

Install:

pip install ironlabs

Migrating from ironaai? The package was renamed to ironlabs in v0.1.0. Update your pip install and from ironlabs import …. Your existing API key keeps working — the SDK accepts both IRONLABS_API_KEY (preferred) and IRONAAI_API_KEY for the migration window.

Export keys for provider you will use:

IRONLABS_API_KEY = "YOUR_IRONLABS_API_KEY"
OPENAI_API_KEY = "YOUR_OPENAI_API_KEY"
ANTHROPIC_API_KEY = "YOUR_ANTHROPIC_API_KEY"

To use this client, you would initialize it like this:

client = IronaAI(
    model_list=["openai/gpt-3.5-turbo", "openai/gpt-4", "anthropic/claude-2"],
)

You can then use it for completions, function calling, and tool binding:

# Regular completion
response = client.completions.create(
    messages=[{"role": "user", "content": "Hello, how are you?"}],
    model_list=["openai/gpt-3.5-turbo", "openai/gpt-4", "anthropic/claude-2"],)

# Function calling
def get_current_weather(location: str, unit: str = "fahrenheit"):
    """Get the current weather in a given location"""
    # Implementation here
    return f"The weather in {location} is 72°F."

tools = [
    {
        "name": "get_current_weather",
        "description": "Get the current weather in a given location",
        "parameters": {
            "type": "object",
            "properties": {
                "location": {"type": "string"},
                "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
            },
            "required": ["location"],
        },
    }
]

messages = [{"role": "user", "content": "What's the weather like in San Francisco?"}]

# Call the model
response = client.completions.create( messages=messages, tools=tools, tool_choice="auto",)

Install Instructions

poetry install .

Push this to PyPi

poetry build
poetry publish

Then users can simply install the package using pip:

pip install ironlabs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ironlabs-0.1.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ironlabs-0.1.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file ironlabs-0.1.0.tar.gz.

File metadata

  • Download URL: ironlabs-0.1.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for ironlabs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7c9ee6566e006d43eb25157ffe36af07775a19df696007b5a50a91ffe2a4c5ce
MD5 995299b9f6e13e386aea43af95774798
BLAKE2b-256 f5f272a0604bf44ff04cd71a34510705579b568e9531e165e9363a07069de5df

See more details on using hashes here.

File details

Details for the file ironlabs-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ironlabs-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for ironlabs-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 67ac88cfab66d089644b6ac86af07a02e07384cfeb5cc8b561cb488c5322bf66
MD5 da30000a23bad7dc82e7ef34c6aa27cb
BLAKE2b-256 1d46df8c0cf44db9fc48da02e70514dcb0ea11c90414ab71e2e49cd6b80da99f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page