gais: Generative AI Suite for Multi-Provider Access
A unified and consistent interface for working with multiple LLM providers.
gais provides:
- Parallel multi-prompt generation: run several prompts at once using a single provider.
- Multi-provider generation: send one prompt to multiple providers and collect all responses together.
- Structured outputs with Pydantic: clean, validated responses using Pydantic models.
- Universal parsing support: uses native parsing when available (e.g., OpenAI .parse), and an automatic fallback parser when it isn’t.
Currently supported providers: OpenAI, DeepSeek, Groq, Anthropic, Fireworks, Gemini, and Ollama.
NOTE: For detailed usage, see the
gaisdocumentation
Installation
Install via pip:
```bash
pip install gais
```
Or from source:
```bash
git https://github.com/hanifsajid/gais.git
cd gais
pip install -e .
```
Usage
from pydantic import BaseModel, Field
from gais import Generator, MultiPromptGenerator, MultiProviderGenerator, DeepSeek, OpenAI
class Capital(BaseModel):
"""Structured Pydantic model representing a capital city."""
capital: str = Field(..., description="The name of the capital city.")
class Joke(BaseModel):
"""Structured Pydantic model representing a joke response."""
joke: str = Field(..., description="A one- or two-sentence joke.")
# Initialize provider
api_key = "YOUR_OPENAI_API_KEY"
openai_provider = OpenAI(model="gpt-4o-mini", api_key=api_key)
1. SINGLE-PROMPT GENERATION
single_gen = Generator(openai_provider)
# ---- Parsed with Pydantic model ----
parsed_response = single_gen.generate(
"What is the capital of France?",
parse=True,
response_format=Capital,
)
print("Parsed Response:", parsed_response.parsed)
# ---- Standard unparsed output ----
std_response = single_gen.generate(
"What is the capital of France?",
parse=False,
)
print("Raw Response:", std_response)
# ---- With custom generation kwargs ----
custom_response = single_gen.generate(
"What is the capital of France?",
parse=True,
response_format=Capital,
temperature=0.2,
max_tokens=50,
)
print("Custom Params Parsed Response:", custom_response.parsed)
2. MULTI-PROMPT GENERATION
multi_prompts = [
"What is the capital of France?",
"Tell me a joke.",
"What is the capital of USA?",
]
# Per-prompt response formats
multi_formats = [Capital, Joke, Capital]
multi_gen = MultiPromptGenerator(provider=openai_provider, max_workers=3)
# ---- Parsed multi-prompt output ----
parsed_multi = multi_gen.run(
multi_prompts,
parse=True,
response_format=multi_formats,
temperature=0.3,
)
for i, r in enumerate(parsed_multi):
print(f"Parsed Multi-Prompt {i+1}: {r.parsed}")
# ---- Standared multi-prompt output ----
raw_multi = multi_gen.run(multi_prompts, parse=False)
for i, r in enumerate(raw_multi):
print(f"Raw Multi-Prompt {i+1}:", r)
3. MULTI-PROVIDER GENERATION
from gais import DeepSeek
providers = [
openai_provider,
DeepSeek(model="deepseek-chat", api_key=DEEPSEEK_API_KEY),
]
multi_provider_gen = MultiProviderGenerator(providers, max_workers=2)
# Per-provider response formats
provider_response_formats = {
providers[0].name: Capital,
providers[1].name: Capital,
}
# Provider-specific overrides
provider_specific_params = {
providers[1].name: {
"temperature": 0.1, # Override for 2nd provider
"max_tokens": 30,
}
}
# ---- Parsed multi-provider output ----
provider_results = multi_provider_gen.run(
prompt="What is the capital of Germany?",
parse=True,
response_format=provider_response_formats,
provider_params=provider_specific_params,
temperature=0.5, # Common parameter (all providers)
max_tokens=80,
)
for r in provider_results:
if r["success"]:
print(f"Provider {r['provider']} Parsed:", r["response"].parsed)
else:
print(f"Provider {r['provider']} Error:", r["error"])
# ---- Raw multi-provider output ----
provider_results_raw = multi_provider_gen.run(
prompt="Tell me a joke.",
parse=False,
provider_params=provider_specific_params,
temperature=0.8,
)
for r in provider_results_raw:
if r["success"]:
print(f"Provider {r['provider']} Raw:", r["response"])
else:
print(f"Provider {r['provider']} Error:", r["error"])
Cite this Project
If you use gais in your work, please cite it as:
@misc{gais,
title = {gais},
author = {Hanif Sajid},
year = {2025},
month = November,
version = {0.1.0},
howpublished = {https://github.com/hanifsajid/gais},
note = {MIT License}
}
Metadata
Release files for gais 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gais-0.1.1.tar.gz | 8.6 kB | Without provenance | Details for gais-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gais-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for gais-0.1.1-py3-none-any.whl |
Total release size: 17.3 kB
Release files / gais-0.1.1.tar.gz
| Download URL | gais-0.1.1.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
547b97ae2d0c01bb6c9b1265bfe596f4661255813a58f633c469200d5ee3b715
|
|
BLAKE2b-256 checksum How to use checksums |
3c9bd01557a17fa68585a61d782f56873a8c752efec5ff1136a00accf44a4fd3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.11.14 Linux/6.11.0-1018-azure
|
Release files / gais-0.1.1-py3-none-any.whl
| Download URL | gais-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e3503112c904503bf1a71cea0301a5e1f467d7dcd0454b532a8e9ecc6a70481c
|
|
BLAKE2b-256 checksum How to use checksums |
b2fb2503678a038585cc016efab9d824d130e55bd513acb38090c22f752a26e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.11.14 Linux/6.11.0-1018-azure
|
Security for gais 0.1.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.