Metadata-Version: 2.4
Name: keiro
Version: 0.12.22
Summary: Keiro client — call the EB1 multi-model ensemble API.
Author: Keiro Engineering
License-Expression: LicenseRef-Proprietary
Project-URL: Homepage, https://pypi.org/project/keiro/
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: <3.14,>=3.11
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.32.2
Requires-Dist: PyYAML>=6.0.1
Requires-Dist: rich>=13.0.0
Provides-Extra: dev
Requires-Dist: pytest>=8.3.2; extra == "dev"
Requires-Dist: ruff>=0.12.0; extra == "dev"

# Keiro

eb1 multi-model ensemble inference. Run multiple frontier models in parallel
and synthesize the best response.

## Quick start

```bash
pip install keiro
PUBLIC_GATEWAY_URL=https://api.keirolabs.ai/v1
keiro setup --gateway-url "$PUBLIC_GATEWAY_URL"
```

```python
from keiro import models

print(models("eb1-preview", "What is machine learning?"))
```

Or from the command line:

```bash
keiro "What is machine learning?"
```

## How it works

eb1 sends your prompt to multiple frontier models (Claude, GPT, Gemini) in
parallel, then a judge synthesizes the strongest elements into a single
response. The result is more accurate and more complete than any individual
model.

## Models

| Model | Description |
|-------|-------------|
| `eb1-preview` (default) | Balanced profile for general-purpose reasoning and coding |
| `eb1-frontier-preview` | Highest-capability profile for difficult reasoning and synthesis |
| `eb1-fast-preview` | Low-latency profile for interactive work |
| `eb1-efficient-preview` | Cost-efficient profile for routine work and high-volume edits |

```python
from keiro import models

# Default adaptive ensemble
answer = models("eb1-preview", "Solve this step by step: what is 23 * 47?")

# Max quality
answer = models("eb1-frontier-preview", "Prove that sqrt(2) is irrational.")

# Low latency
answer = models("eb1-fast-preview", "Summarize this in one sentence.")
```

## Prompt-first API

```python
import sys

from keiro import models

# Structured response with usage metadata
reply = models.response("eb1-preview", "Explain quantum computing.")
print(reply.text)
print(reply.usage)

# Reusable model binding with fixed parameters
creative = models.instance("eb1-preview", temperature=0.8)
print(creative("Write a limerick about debugging."))

# Streaming
for chunk in models.stream("eb1-preview", "Draft a launch email."):
    print(chunk, end="")

# Responses streaming with reasoning summaries on a separate channel
for chunk in models.responses_stream(
    "eb1-preview",
    input="Compare two database designs.",
    reasoning={"summary": "auto"},
    on_reasoning_summary=lambda summary: print(f"thinking: {summary}", file=sys.stderr),
):
    print(chunk, end="")
```

## Full client

```python
from keiro import Client

client = Client()

# Chat completions API
response = client.chat(
    messages=[{"role": "user", "content": "Explain quantum computing."}],
    model="eb1-preview",
)
print(response["choices"][0]["message"]["content"])

# Rate limit visibility
print(client.rate_limits)
# RateLimitInfo(limit_requests=1000, remaining_requests=999, ...)

client.close()
```

## CLI

```bash
keiro "What is ML?"                 # one-shot response
keiro                               # interactive REPL
keiro gui                           # local browser chat UI
keiro -m eb1-fast-preview "Quick answer"    # specific model
echo context | keiro "Summarize"    # pipe context as input
keiro --no-search "Use only prior knowledge" # opt out of hosted web search
keiro setup                         # configure credentials
keiro models                        # list available models
keiro endpoint --list               # list configured endpoint choices
```

In the interactive REPL, streamed code fences render as numbered code blocks.
Use `/copy [n]` to copy a block from the last assistant reply.
For registered eb1 models, the CLI requests safe reasoning summaries and shows
each available segment as terminal activity. Summary text stays out of the
assistant answer, conversation history, copied code, and piped stdout.

The startup mark follows `KEIRO_TERMINAL_THEME=light|dark` when set, then the
terminal background reported by `COLORFGBG`; it never infers terminal contrast
from the operating-system appearance. The conservative fallback for terminals
that publish neither signal is the dark-terminal colorway.

Adaptive public preview models offer hosted web search by default with
`tool_choice="auto"`; the model decides whether to use it. `/search` toggles the
declaration for the session, and `--no-search` disables it for a one-shot run.
Declaring hosted search can narrow the eligible provider pool.

`keiro gui` opens the local browser chat UI in Chrome when available. If
startup takes longer than expected, the CLI prints a manual URL and log path.

### Versioned v24b comparison endpoint

This source recognizes the generation-pinned v24b comparison endpoint:

```bash
keiro endpoint v24b
keiro "Run a comparison prompt"
keiro endpoint public  # return to the current public default
```

`v24b`, `v24`, `v24b-preview`, and `v24b-weights` select
`https://api.keirolabs.ai/v24b/v1`; they do not change the requested model
name. Availability is operator-controlled. As of 2026-07-21 the server lane is
prepared but not live and this client change has not been published to PyPI.
Do not treat endpoint selection or package installation as proof that the
server is active; activation requires the public path and exact pinned bundle
to pass the production acceptance gates.

AB2 (the `eb1-gnn-v33ab2-07-17` bundle) is different: it is a router-weight
promotion behind the ordinary public `eb1-preview` service, not a versioned
client endpoint. When that promotion is active, use `keiro endpoint public`
and request `eb1-preview`. The client deliberately does not advertise `ab2`
or `v33b` endpoint aliases; a separately addressable snapshot would require a
dedicated server lane and public edge route first.

## Configuration

**Interactive setup** (recommended):

```bash
PUBLIC_GATEWAY_URL=https://api.keirolabs.ai/v1
keiro setup --gateway-url "$PUBLIC_GATEWAY_URL"
```

This validates your API key against the gateway and saves credential metadata
to `~/.keiro/credentials`. Secret bytes are stored in owner-only sidecar files
under `~/.keiro/secrets/`, and the metadata file stores `file://` references.

**Explicit arguments**:

```python
from keiro import Client

client = Client(api_key="your-key", base_url="https://api.keirolabs.ai/v1")
```

API-key and endpoint precedence is explicit arguments, then credentials file.
Runtime credential and gateway URL environment variables are ignored; run
`keiro setup`, `keiro endpoint public`, or `keiro endpoint local` to update
saved credentials.

## Requirements

- Python 3.11+
- No GPU required (inference runs on hosted infrastructure)
