Skip to main content

pig-llm

PyPI version Python

Unified multi-provider LLM API for Python.

Features

  • 🔌 Multi-provider support: OpenAI, Anthropic, Google, and more
  • 🎯 Unified interface: Same API across all providers
  • 🔄 Streaming support: Real-time token streaming
  • 🛡️ Error handling: Automatic retries and fallbacks
  • 📊 Usage tracking: Token counting and cost estimation

Installation

pip install pig-llm

Quick Start

from pig_llm import LLM

# Initialize with API key
llm = LLM(provider="openai", api_key="sk-...")

# Simple completion
response = llm.complete("What is the meaning of life?")
print(response.content)

# Streaming
for chunk in llm.stream("Tell me a story"):
    print(chunk.content, end="", flush=True)

# With system message
response = llm.complete(
    "Translate to Spanish",
    system="You are a helpful translator",
)

Supported Providers

Core Providers

  • OpenAI - GPT-4, GPT-3.5, etc.
  • Anthropic - Claude 3, Claude 2
  • Google - Gemini Pro, Gemini Ultra
  • Azure OpenAI - Azure-hosted OpenAI models

Additional Providers

  • Groq - Ultra-fast LLM inference
  • Mistral - Mistral AI models
  • OpenRouter - Access to multiple models
  • Amazon Bedrock - AWS-hosted foundation models
  • xAI (Grok) - xAI's Grok models
  • Cerebras - Fastest inference speeds
  • Cohere - Command models for enterprise
  • Perplexity - Search-augmented LLMs
  • DeepSeek - Chinese LLM with strong coding
  • Together AI - Open-source model hosting

Configuration

from pig_llm import LLM, Config

config = Config(
    provider="openai",
    model="gpt-4",
    temperature=0.7,
    max_tokens=1000,
    timeout=30,
)

llm = LLM(config=config)

Provider-Specific Examples

Amazon Bedrock

# Uses AWS credentials from environment
llm = LLM(provider="bedrock", api_key="us-east-1")  # region as api_key
response = llm.complete("Hello", model="anthropic.claude-3-sonnet-20240229-v1:0")

xAI (Grok)

llm = LLM(provider="xai", api_key="xai-...")
response = llm.complete("What's happening?", model="grok-beta")

Cerebras

llm = LLM(provider="cerebras", api_key="csk-...")
response = llm.complete("Fast inference!", model="llama3.1-8b")

Cohere

llm = LLM(provider="cohere", api_key="...")
response = llm.complete("Hello", model="command-r-plus")

Perplexity

llm = LLM(provider="perplexity", api_key="pplx-...")
response = llm.complete("What's the latest news?", model="llama-3.1-sonar-large-128k-online")
# Citations available in response.metadata["citations"]

DeepSeek

llm = LLM(provider="deepseek", api_key="...")
response = llm.complete("写一段Python代码", model="deepseek-chat")

Together AI

llm = LLM(provider="together", api_key="...")
response = llm.complete("Hello", model="meta-llama/Llama-3-70b-chat-hf")

License

MIT

Metadata

Release files for pig-llm 0.2.0

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

Source distribution (sdist)

Source distribution for pig-llm 0.2.0
File Size Uploaded
pig_llm-0.2.0.tar.gz 62.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pig-llm 0.2.0
File Interpreter ABI Platform
pig_llm-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 119.3 kB

Release files / pig_llm-0.2.0.tar.gz

Download URL pig_llm-0.2.0.tar.gz
Size 62.3 kB
Tags Source
SHA-256 checksum
How to use checksums
88768504886aa468f4db1d5c66417cfa21e867bbe27366263a12b538eebbebba
BLAKE2b-256 checksum
How to use checksums
d1c6c499f26fe7c469873a7db9e90c3933e9c38ef5c6ef331fcab2fcbd4696c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 4, 2026.

Transparency log

Release files / pig_llm-0.2.0-py3-none-any.whl

Download URL pig_llm-0.2.0-py3-none-any.whl
Size 57.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ad8e76a50a0ef8257972e4398e7cb9c5994c2fba8fc514e0629eacdb9e70c9d
BLAKE2b-256 checksum
How to use checksums
c400d1c4445b982fa131eedc60f6e715606a1805ddd8c909ccdeb58f42b55c59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 4, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.1

2 release files

0.0.2

2 release files

0.0.1

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