Skip to main content

A high-level Python SDK for Large Language Models with automatic tool execution, structured output support, multi-agent workflows, and evaluation data recording

Project description

GlueLLM

TL;DR: A high-level Python SDK for LLMs that handles the annoying stuff (tools, retries, structured output, batching) so you can ship features instead of glue code.

GlueLLM is opinionated in the “I’ve been burned by this in production” way. If you like sensible defaults, clear APIs, and fewer bespoke wrappers, you’ll feel at home.

Works great with Spiderweb

If you’re building RAG, you probably don’t just need LLM calls — you need crawling, extraction, chunking, validation, and storage too. That’s Spiderweb.

  • GlueLLM: LLM calls + tool execution + structured output + embeddings + batching
  • Spiderweb: documents/web → clean chunks → vector store → query

Tiny “together” example:

import asyncio
from gluellm import GlueLLM
from spiderweb import Spiderweb

async def main():
    async with Spiderweb(llm_client=GlueLLM()) as web:
        await web.crawl("https://example.com", ingest=True, save_to="./crawled")
        results = await web.query("What is this site about?", top_k=5)
        print(results.chunks[0]["content"][:200])

asyncio.run(main())

What is this?

GlueLLM is a high-level SDK that makes working with LLMs actually pleasant:

  • You call complete() or structured_complete() and get results.
  • Tools are plain Python functions.
  • Retries and error classification are built-in.
  • Batching and rate limiting are first-class.
  • Providers are unified via any-llm-sdk.

Why you might like it

  • Zero ceremony: minimal code to get real results
  • Tool execution loop: automatic tool calling orchestration
  • Structured output: Pydantic models, validated
  • Provider-agnostic: one API for OpenAI, Anthropic, XAI, and others
  • Embeddings: same ergonomics + error handling
  • Batch processing: concurrency control, retry strategies, key pools
  • Observability hooks: logging + optional tracing

Why you might not

  • If you want a thin client that exposes every raw provider knob, GlueLLM isn’t trying to be that.
  • If you hate opinions, you’ll hate opinions (mine included).

Installation

# Using uv (recommended)
uv pip install gluellm

# From source (dev)
uv pip install -e ".[dev]"

Quick start

Simple completion

import asyncio
from gluellm.api import complete

async def main():
    result = await complete(
        user_message="What is the capital of France?",
        system_prompt="You are a helpful geography assistant.",
    )
    print(result.final_response)

asyncio.run(main())

Tool calling (tools are just functions)

import asyncio
from gluellm.api import complete

def get_weather(location: str, unit: str = "celsius") -> str:
    """Get the current weather for a location."""
    return f"Weather in {location}: 22°{unit[0].upper()}, sunny"

async def main():
    result = await complete(
        user_message="What's the weather in Tokyo and Paris?",
        system_prompt="Use get_weather for weather queries.",
        tools=[get_weather],
    )
    print(result.final_response)

asyncio.run(main())

Structured output

import asyncio
from pydantic import BaseModel, Field
from typing import Annotated

from gluellm.api import structured_complete

class PersonInfo(BaseModel):
    name: Annotated[str, Field(description="Full name")]
    age: Annotated[int, Field(description="Age in years")]
    city: Annotated[str, Field(description="City of residence")]

async def main():
    person = await structured_complete(
        user_message="Extract info: John Smith, 35, lives in Seattle",
        response_format=PersonInfo,
    )
    print(person.model_dump())

asyncio.run(main())

Embeddings

import asyncio
from gluellm import embed

async def main():
    result = await embed("Hello, world!")
    print(result.dimension, result.tokens_used)

asyncio.run(main())

Configuration (the boring part)

Providers are configured via environment variables:

export OPENAI_API_KEY=sk-...
export ANTHROPIC_API_KEY=sk-ant-...
export XAI_API_KEY=xai-...

Models use provider:model strings:

  • openai:gpt-4o-mini
  • anthropic:claude-3-5-sonnet-20241022

Docs (when you want the details)

GlueLLM keeps deeper docs in docs/ so the README stays readable:

More runnable examples live in examples/.

Contributing

PRs welcome. Please read CONTRIBUTING.md.

License

MIT — see LICENSE.

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

gluellm-1.1.4.tar.gz (168.2 kB view details)

Uploaded Source

Built Distribution

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

gluellm-1.1.4-py3-none-any.whl (153.2 kB view details)

Uploaded Python 3

File details

Details for the file gluellm-1.1.4.tar.gz.

File metadata

  • Download URL: gluellm-1.1.4.tar.gz
  • Upload date:
  • Size: 168.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for gluellm-1.1.4.tar.gz
Algorithm Hash digest
SHA256 f6eb33cb19e78b01e75c9070d6dcdbc0b4ae121f05e717fd624cd5d6873a5480
MD5 c4d4da64c6ad453ee835d5c2d1a8223e
BLAKE2b-256 c0d86912b8c236c7e47700a9ee202eb6ede7a381f5c3a9abc09f2ddaf9e34082

See more details on using hashes here.

File details

Details for the file gluellm-1.1.4-py3-none-any.whl.

File metadata

  • Download URL: gluellm-1.1.4-py3-none-any.whl
  • Upload date:
  • Size: 153.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for gluellm-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 bca4c692a3173f99dbcfd6b3d336b2d0cb5114dc3cbfee742d6995493a858bfa
MD5 61587c1e8dccb5a7e1741379fe9fcade
BLAKE2b-256 2b204c11e06b499dc9fa5740354ab00a82d721dfe25c94adc66246ed26551c9d

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