Skip to main content

anyask

A single-responsibility Python package for one job: call an LLM provider, get its raw response back. No routing, no fallback, no retries - you always name the provider and model explicitly, and you always get the same normalized AskResponse shape back regardless of which of the 17 supported vendors you called.

import anyask

response = anyask.ask(
    "Say hello in one word.",
    provider="anthropic",
    model="claude-haiku-4-5-20251001",
    api_key="sk-...",  # or set ANTHROPIC_API_KEY
)

print(response.content)          # "Hello"
print(response.usage)            # TokenUsage(prompt_tokens=..., completion_tokens=..., total_tokens=...)
print(response.finish_reason)    # "end_turn" (raw, provider-specific - never normalized)
print(response.provider)         # "anthropic"
print(response.model)            # "claude-haiku-4-5-20251001"

Documentation

Full documentation, including the Providers reference table, Quickstart, and generated API Reference, is available at:

Supported providers

openai, anthropic, gemini, vertexai, azure, mistral, cohere, bedrock, oci, and the nine OpenAI-compatible vendors: deepseek, groq, xai, together, fireworks, cerebras, perplexity, openrouter, moonshot.

Install

A bare pip install anyask pulls in zero provider SDKs - only PyYAML (for the built-in model catalog). Install the extra(s) for the provider(s) you actually use:

pip install anyask[anthropic]
pip install anyask[openai,gemini]
pip install anyask[all]       # every provider SDK

Provider SDK imports are lazy: resolving one provider by name never imports another provider's SDK, so import anyask always succeeds even in an environment with no provider SDKs installed at all.

API

def ask(prompt: str, *, provider: str, model: str, **kwargs) -> AskResponse: ...
async def ask_async(prompt: str, *, provider: str, model: str, **kwargs) -> AskResponse: ...
def list_models(provider: str, **kwargs) -> list[str]: ...
async def list_models_async(provider: str, **kwargs) -> list[str]: ...
def get_provider(provider: str, **config) -> Provider: ...

**kwargs passed to ask/ask_async/list_models is split automatically: construction keys (api_key, endpoint, api_version, deployment, region, project, compartment_id) go to the provider's constructor; everything else (temperature, max_tokens, ...) is forwarded to the generation call unchanged. Any key a given provider doesn't recognize is simply ignored, so the same kwargs dict can be handed to any provider.

ask() / ask_async()

response = anyask.ask("What is 2+2?", provider="openai", model="gpt-4o-mini")

response = await anyask.ask_async(
    "What is 2+2?", provider="openai", model="gpt-4o-mini", temperature=0.0,
)

list_models() / list_models_async()

models = anyask.list_models("anthropic", api_key="sk-...")
# ['claude-opus-4-8', 'claude-sonnet-4-5', ...]

Raises anyask.ProviderNotFoundError if the resolved provider doesn't expose a live model-listing endpoint (e.g. Perplexity returns a static list instead).

get_provider() - reusable provider instances

ask() builds a fresh provider (and its underlying SDK client) on every call. If you're making many calls against the same provider/credentials - e.g. resolving dozens of prompts against one Anthropic API key in a loop - construct once and reuse:

provider = anyask.get_provider("anthropic", api_key="sk-...")

for prompt in prompts:
    response = provider.generate_sync(prompt, model="claude-haiku-4-5-20251001")

This avoids rebuilding the SDK client (a fresh boto3.client(), re-reading ~/.oci/config, etc.) on every single call.

Errors

class AskLLMError(Exception): ...
class ProviderNotFoundError(AskLLMError): ...   # unknown provider name, or missing capability
class ProviderError(AskLLMError): ...            # provider call failed - raised with `from exc`
class ProviderAuthError(ProviderError): ...       # missing/invalid credentials at construction

Every provider call failure is raised as ProviderError(...) from exc, so err.__cause__ is always the original SDK exception - inspect it if you need vendor-specific error details (status codes, error types, etc.).

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anyask-0.1.0.tar.gz (22.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anyask-0.1.0-py3-none-any.whl (34.1 kB view details)

Uploaded Python 3

File details

Details for the file anyask-0.1.0.tar.gz.

File metadata

  • Download URL: anyask-0.1.0.tar.gz
  • Upload date:
  • Size: 22.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for anyask-0.1.0.tar.gz
Algorithm Hash digest
SHA256 343826df0d5d6aabd2b3838e7c9f7080565022d10f02d9126f4952104406f513
MD5 108ba40816764a645d390588532a7cd7
BLAKE2b-256 733bc659fda466f20385c7695ca60ed021affa923c4ed167c149c3d639bf1b98

See more details on using hashes here.

Provenance

The following attestation bundles were made for anyask-0.1.0.tar.gz:

Publisher: publish-pypi.yml on Geeks-Trident-LLC/anyask

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file anyask-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: anyask-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 34.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for anyask-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 858f48bc2c30d53b1f4771019cbd8d7f4ecdcccb5ec7f51fcb65ee9e5470334d
MD5 189d1c909507909026cbfb55425a6b00
BLAKE2b-256 bddbb056bf336ea9ef5414ddc01700824a7e58b47c9ccd09352416d456a89475

See more details on using hashes here.

Provenance

The following attestation bundles were made for anyask-0.1.0-py3-none-any.whl:

Publisher: publish-pypi.yml on Geeks-Trident-LLC/anyask

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page