Metadata-Version: 2.4
Name: yachay
Version: 0.1.1
Summary: Python SDK for Yachay — Condor Models inference API (OpenAI-compatible)
Author-email: Chicha Technology LLC <hello@chichatechnology.com>
License: MIT
Project-URL: Homepage, https://yachaymodels.com
Project-URL: Documentation, https://yachaymodels.com/docs
Project-URL: Bug Tracker, https://yachaymodels.com/support
Keywords: yachay,condor,llm,inference,openai,ai
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.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.27
Requires-Dist: typer>=0.12
Requires-Dist: rich>=13.0
Requires-Dist: keyring>=24.0
Requires-Dist: click>=8.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"

# Yachay Python SDK

Python client for [Yachay — Condor Models](https://yachaymodels.com) inference API.
Designed to feel like the OpenAI SDK so migrating existing code takes minutes.

## Install

```bash
pip install yachay
```

Requires Python 3.9+.

## Quickstart

```python
import yachay

client = yachay.Client()  # reads YACHAY_API_KEY from environment

response = client.chat.completions.create(
    model="llama-3.1-8b",
    messages=[{"role": "user", "content": "Explain gradient descent in one paragraph."}],
)
print(response.choices[0].message.content)
```

## Authentication

Create a customer API key in the [Yachay dashboard](https://yachaymodels.com/dashboard/api-access).
Keys are prefixed `yck_`.

**Recommended — environment variable:**

```bash
export YACHAY_API_KEY="yck_your_key_here"
```

**Or pass directly:**

```python
client = yachay.Client(api_key="yck_your_key_here")
```

## Available models

Two models are currently available for inference:

| Model ID | Description |
|---|---|
| `llama-3.1-8b` | Meta Llama 3.1 8B — fast general-purpose chat |
| `deepseek-r1-distill-llama-8b` | DeepSeek R1 distilled into Llama 8B — strong reasoning |

To list available models programmatically:

```python
models = client.models.list()
for model in models.data:
    print(model.id)
```

## Chat completions

```python
response = client.chat.completions.create(
    model="deepseek-r1-distill-llama-8b",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is the capital of Peru?"},
    ],
    max_tokens=256,
    temperature=0.7,
)

# Access the generated text
print(response.choices[0].message.content)

# Access token usage
print(f"Tokens used: {response.usage.total_tokens}")
```

## Context manager

```python
with yachay.Client() as client:
    response = client.chat.completions.create(
        model="llama-3.1-8b",
        messages=[{"role": "user", "content": "Hello!"}],
    )
    print(response.choices[0].message.content)
# HTTP connection pool is closed automatically
```

## Migrating from OpenAI

The client mirrors the OpenAI SDK's nested-namespace pattern. Replace:

```python
# Before
import openai
client = openai.OpenAI(api_key="sk-...")
response = client.chat.completions.create(model="gpt-4o", messages=[...])
```

with:

```python
# After
import yachay
client = yachay.Client(api_key="yck_...")
response = client.chat.completions.create(model="llama-3.1-8b", messages=[...])
```

Response objects share the same shape: `.choices[0].message.content`, `.usage.total_tokens`, etc.

## Error handling

```python
from yachay import AuthError, RateLimitError, APIError

try:
    response = client.chat.completions.create(...)
except AuthError:
    print("Invalid API key")
except RateLimitError:
    print("Slow down — you are being rate-limited")
except APIError as e:
    print(f"API error {e.status}: {e.body}")
```

All errors are subclasses of `yachay.YachayError`.

## Custom base URL and timeout

```python
client = yachay.Client(
    api_key="yck_...",
    base_url="https://api.yachaymodels.com/v1",  # default; override for testing
    timeout=30.0,  # seconds
)
```

## What v1 does NOT include

- **Streaming** — `stream=True` is not yet supported. Submit a feature request at [yachaymodels.com/support](https://yachaymodels.com/support).
- **Fine-tuning job management** — submitting training jobs, downloading adapters, and managing the fine-tuning pipeline are not available through this SDK in v1. Use the [Yachay web dashboard](https://yachaymodels.com/dashboard) for job management.
- **Embeddings** — not available in v1.

## Documentation

Full API reference and guides at [yachaymodels.com/docs](https://yachaymodels.com/docs).

## License

MIT — see [LICENSE](../LICENSE) for details.
