Metadata-Version: 2.4
Name: scalexi_llm
Version: 0.1.51
Summary: A comprehensive multi-provider LLM proxy library with unified interface
Home-page: https://github.com/scalexi/scalexi_llm
Author: scalex_innovation
Author-email: scalex_innovation@gmail.com
Keywords: llm,ai,openai,anthropic,gemini,groq,deepseek,grok,qwen,ollama,exa,proxy,api
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: openai
Requires-Dist: anthropic
Requires-Dist: google-genai
Requires-Dist: groq
Requires-Dist: pymupdf
Requires-Dist: xai-sdk
Requires-Dist: python-docx
Requires-Dist: pydantic
Requires-Dist: python-dotenv
Requires-Dist: exa-py
Requires-Dist: serpapi>=1.0.2
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# ScaleXI LLM

A multi-provider LLM proxy that gives you **one unified API** for many model providers.

- **10 Providers**: OpenAI, Anthropic (Claude), Google (Gemini), Groq, DeepSeek, Alibaba (Qwen), Grok (xAI), Moonshot (Kimi), local **Ollama**, and **RunPod (native API)**
- **59 Built-in Model Configurations**: GPT-5.x, Claude Opus/Sonnet/Haiku 4.x, Gemini 3.x/2.5, DeepSeek V4, Kimi K3, Qwen, Grok and more, with pricing, limits and capabilities in one registry
- **Structured Outputs**: Pydantic schemas with validation and optional model fallbacks
- **Streaming**: `stream=True` yields chunks with final token usage and cost
- **Vision & Files**: Single/multi-image input, PDF/DOCX/TXT/JSON handling, and automatic vision fallbacks
- **Web Search**: Exa and/or SerpAPI for retrieval-augmented answers (optionally restricted to one domain)
- **Cost Tracking**: Token usage and USD cost for every call
- **LangSmith Tracing**: Optional — set `enable_tracing=True` and every call is traced

## Installation

```bash
pip install scalexi_llm
```

Set the API keys for the providers you use (e.g. `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `GEMINI_API_KEY`, `MOONSHOT_API_KEY`) in your environment or a `.env` file.

## Quick Example

```python
from scalexi_llm import LLMProxy

llm = LLMProxy()

response, execution_time, token_usage, cost = llm.ask_llm(
    model_name="gpt-5.6-terra",
    system_prompt="You are a helpful assistant.",
    user_prompt="Explain quantum computing in simple terms."
)

print(response, cost)
```

## Structured Output

```python
from pydantic import BaseModel

class Answer(BaseModel):
    summary: str
    key_points: list[str]

response, _, _, _ = llm.ask_llm(
    model_name="claude-sonnet-4-6",
    user_prompt="Summarize the benefits of solar energy.",
    schema=Answer
)
answer = Answer.model_validate_json(response)
```

## Streaming

```python
for chunk in llm.ask_llm(model_name="gemini-flash-latest", user_prompt="Tell me a story", stream=True):
    print(chunk.delta, end="", flush=True)
    if chunk.done:
        print("\n", chunk.token_usage, chunk.cost)
```

## Model Listing

```python
import json
llm = LLMProxy(verbose=0)
print(json.dumps(llm.list_available_models(), indent=2))
```

## Domain-Restricted Web Search

```python
response, _, _, _ = llm.ask_llm(
    model_name="gpt-5.6-terra",
    user_prompt="Find the admissions requirements",
    websearch=True,
    search_tool="both",
    search_domain="binbaz.org.sa"
)
```

## LangSmith Tracing (Optional)

```python
# pip install langsmith  (+ set LANGSMITH_API_KEY in .env)
llm = LLMProxy(enable_tracing=True)

response, exec_time, token_usage, cost = llm.ask_llm(
    model_name="gpt-5.6-terra",
    user_prompt="What is quantum computing?"
)
# Token usage, cost, provider, and model are logged to LangSmith
```

## Features at a Glance

- One `LLMProxy` class and one `ask_llm` function for all providers
- Text, files, images, web search and streaming through the same call
- Local models via `ollama/<model>` and custom endpoints via `runpod/<provider>/<model>`
- Pydantic-based structured outputs with retries and opt-in model fallbacks
- Vision fallback when the chosen model doesn't support images
- Token and cost accounting for every call, including search and fallback steps
