unifiedai-sdk


Nameunifiedai-sdk JSON
Version 1.0.4 PyPI version JSON
download
home_pageNone
SummaryUnified SDK for multi-provider LLM comparison (Cerebras, AWS Bedrock) with OpenAI-compatible interface.
upload_time2025-10-13 08:52:54
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT
keywords bedrock cerebras comparison llm openai-compatible sdk
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # UnifiedAI SDK

OpenAI-compatible Python SDK unifying multiple providers (Cerebras, AWS Bedrock) with Solo and Comparison modes, strict models, and built‑in telemetry.

## Highlights
- OpenAI-like API: `UnifiedAI().chat.completions.create(...)` (sync) and `AsyncUnifiedAI` (async)
- Pluggable adapters: Cerebras, Bedrock (extensible)
- Modes: Solo and side‑by‑side Comparison
- Observability: structured logs, Prometheus metrics (SDK), tracing hooks
- Credentials: pass at client construction or use env

## Install
From PyPI (core):
```bash
pip install unifiedai-sdk
```

Optional extras:
```bash
# Cerebras Cloud SDK integration
pip install "unifiedai-sdk[cerebras]"

# HTTP/2 support for httpx
pip install "unifiedai-sdk[http2]"
```

From GitHub (optional):
```bash
pip install git+https://github.com/<your-org-or-user>/<your-repo>.git#subdirectory=cerebras
```

## Usage

### Sync (scripts/CLI)
```python
from unifiedai import UnifiedAI

client = UnifiedAI(
    provider="cerebras",
    model="llama3",
    credentials={"api_key": "csk-..."},  # or set CEREBRAS_KEY in env
)
resp = client.chat.completions.create(
    messages=[{"role": "user", "content": "Hello"}]
)
print(resp.choices[0].message["content"])
```

### Async (web backends)
```python
from unifiedai import AsyncUnifiedAI

async with AsyncUnifiedAI(provider="cerebras", model="llama3") as client:
    resp = await client.chat.completions.create(
        messages=[{"role": "user", "content": "Hello"}]
    )
```

### Streaming (async)
```python
async with AsyncUnifiedAI(provider="cerebras", model="llama3") as client:
    async for chunk in client.chat.completions.stream(
        messages=[{"role": "user", "content": "Stream this"}]
    ):
        print(chunk.delta.get("content", ""), end="")
```

### Comparison (two providers)
```python
from unifiedai import AsyncUnifiedAI

async with AsyncUnifiedAI() as client:
    result = await client.compare(
        providers=["cerebras", "bedrock"],
        model="llama3",
        messages=[{"role": "user", "content": "Compare outputs"}],
    )
    print(result.winner, result.comparative_metrics.speed_difference_ms)
```

## Credentials
- Precedence: per‑provider credentials > global client credentials > environment (SDKConfig).
- Cerebras: set `CEREBRAS_KEY` or pass `credentials={"api_key": "..."}`.
- Bedrock: planned; wire `credentials_by_provider` similarly.

## FastAPI demo (Swagger UI)
```bash
uvicorn apps.chat.backend:app --reload --port 8000
# Swagger UI: http://localhost:8000/docs
```

## Project Structure
- `src/unifiedai/`: SDK implementation (clients, adapters, models, core)
- `examples/`: usage examples (solo, streaming, comparison)
- `apps/chat/`: demo FastAPI backend
- `tests/`: unit tests

## License
MIT

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "unifiedai-sdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "bedrock, cerebras, comparison, llm, openai-compatible, sdk",
    "author": null,
    "author_email": "Your Team <team@example.com>",
    "download_url": "https://files.pythonhosted.org/packages/a7/5d/b936b5fb3af5fa47caab0935b9346dd997a49c35a2809b2c85f172415067/unifiedai_sdk-1.0.4.tar.gz",
    "platform": null,
    "description": "# UnifiedAI SDK\n\nOpenAI-compatible Python SDK unifying multiple providers (Cerebras, AWS Bedrock) with Solo and Comparison modes, strict models, and built\u2011in telemetry.\n\n## Highlights\n- OpenAI-like API: `UnifiedAI().chat.completions.create(...)` (sync) and `AsyncUnifiedAI` (async)\n- Pluggable adapters: Cerebras, Bedrock (extensible)\n- Modes: Solo and side\u2011by\u2011side Comparison\n- Observability: structured logs, Prometheus metrics (SDK), tracing hooks\n- Credentials: pass at client construction or use env\n\n## Install\nFrom PyPI (core):\n```bash\npip install unifiedai-sdk\n```\n\nOptional extras:\n```bash\n# Cerebras Cloud SDK integration\npip install \"unifiedai-sdk[cerebras]\"\n\n# HTTP/2 support for httpx\npip install \"unifiedai-sdk[http2]\"\n```\n\nFrom GitHub (optional):\n```bash\npip install git+https://github.com/<your-org-or-user>/<your-repo>.git#subdirectory=cerebras\n```\n\n## Usage\n\n### Sync (scripts/CLI)\n```python\nfrom unifiedai import UnifiedAI\n\nclient = UnifiedAI(\n    provider=\"cerebras\",\n    model=\"llama3\",\n    credentials={\"api_key\": \"csk-...\"},  # or set CEREBRAS_KEY in env\n)\nresp = client.chat.completions.create(\n    messages=[{\"role\": \"user\", \"content\": \"Hello\"}]\n)\nprint(resp.choices[0].message[\"content\"])\n```\n\n### Async (web backends)\n```python\nfrom unifiedai import AsyncUnifiedAI\n\nasync with AsyncUnifiedAI(provider=\"cerebras\", model=\"llama3\") as client:\n    resp = await client.chat.completions.create(\n        messages=[{\"role\": \"user\", \"content\": \"Hello\"}]\n    )\n```\n\n### Streaming (async)\n```python\nasync with AsyncUnifiedAI(provider=\"cerebras\", model=\"llama3\") as client:\n    async for chunk in client.chat.completions.stream(\n        messages=[{\"role\": \"user\", \"content\": \"Stream this\"}]\n    ):\n        print(chunk.delta.get(\"content\", \"\"), end=\"\")\n```\n\n### Comparison (two providers)\n```python\nfrom unifiedai import AsyncUnifiedAI\n\nasync with AsyncUnifiedAI() as client:\n    result = await client.compare(\n        providers=[\"cerebras\", \"bedrock\"],\n        model=\"llama3\",\n        messages=[{\"role\": \"user\", \"content\": \"Compare outputs\"}],\n    )\n    print(result.winner, result.comparative_metrics.speed_difference_ms)\n```\n\n## Credentials\n- Precedence: per\u2011provider credentials > global client credentials > environment (SDKConfig).\n- Cerebras: set `CEREBRAS_KEY` or pass `credentials={\"api_key\": \"...\"}`.\n- Bedrock: planned; wire `credentials_by_provider` similarly.\n\n## FastAPI demo (Swagger UI)\n```bash\nuvicorn apps.chat.backend:app --reload --port 8000\n# Swagger UI: http://localhost:8000/docs\n```\n\n## Project Structure\n- `src/unifiedai/`: SDK implementation (clients, adapters, models, core)\n- `examples/`: usage examples (solo, streaming, comparison)\n- `apps/chat/`: demo FastAPI backend\n- `tests/`: unit tests\n\n## License\nMIT\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Unified SDK for multi-provider LLM comparison (Cerebras, AWS Bedrock) with OpenAI-compatible interface.",
    "version": "1.0.4",
    "project_urls": null,
    "split_keywords": [
        "bedrock",
        " cerebras",
        " comparison",
        " llm",
        " openai-compatible",
        " sdk"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b24f92cce0e0c3b10a3caa971c020d8d164ba6fcf2788dfbb2c13e490df588e2",
                "md5": "3b20492fdc558eefe4175e3b3ce2cad2",
                "sha256": "c7e12d1667cea55b7fd3616c65f3d5819cca906328ae06505b8b6fdb9fb15639"
            },
            "downloads": -1,
            "filename": "unifiedai_sdk-1.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3b20492fdc558eefe4175e3b3ce2cad2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 23693,
            "upload_time": "2025-10-13T08:52:52",
            "upload_time_iso_8601": "2025-10-13T08:52:52.449693Z",
            "url": "https://files.pythonhosted.org/packages/b2/4f/92cce0e0c3b10a3caa971c020d8d164ba6fcf2788dfbb2c13e490df588e2/unifiedai_sdk-1.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a75db936b5fb3af5fa47caab0935b9346dd997a49c35a2809b2c85f172415067",
                "md5": "b7fda3991a3fd359d217dd9255485775",
                "sha256": "2fe2c7a8054c171b7b4e1a0c3a9687a1cd02e3e2f187f7e5c5b5744129b80b60"
            },
            "downloads": -1,
            "filename": "unifiedai_sdk-1.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "b7fda3991a3fd359d217dd9255485775",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 17218,
            "upload_time": "2025-10-13T08:52:54",
            "upload_time_iso_8601": "2025-10-13T08:52:54.710591Z",
            "url": "https://files.pythonhosted.org/packages/a7/5d/b936b5fb3af5fa47caab0935b9346dd997a49c35a2809b2c85f172415067/unifiedai_sdk-1.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-13 08:52:54",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "unifiedai-sdk"
}
        
Elapsed time: 0.44304s