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 18 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"

What anyask does (and doesn't) do

prompt is always a plain string; AskResponse.content is always a plain string. That single-string-in, single-string-out contract is what "raw response, one function, no magic" means in practice.

Does: one text prompt → one text completion, the same signature across all 18 providers, with provider-native extras (temperature, max_tokens, reasoning, anything else a given provider's SDK call accepts) reachable via **kwargs, and everything else the SDK response carries reachable via AskResponse.raw.

Doesn't:

  • Multi-turn conversations - no messages=[...] history, no session state; every ask() is one independent turn.
  • System prompts - not part of the contract. A few providers happen to accept one through a provider-specific **kwargs name (Anthropic's/Bedrock's system=, Gemini's system_instruction=), but that's incidental provider behavior, not something anyask guarantees or normalizes - it silently doesn't work on the rest.
  • Multi-modal input - text only, no images/audio/files.
  • Structured/multi-modal output - content is always plain text; tool calls or other structured response parts are only reachable via raw, not a normalized field.
  • Streaming - not implemented by any provider yet.

See SPEC.md's out-of-scope list for the full picture, including why each of these stays out (or isn't in yet).

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, reasoning: bool = False, **kwargs) -> AskResponse: ...
async def ask_async(prompt: str, *, provider: str, model: str, reasoning: bool = False, **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,
)

Pass reasoning=True for extended/deliberate reasoning, using each provider's own real mechanism (Anthropic extended thinking, OpenAI/OpenAI-compatible reasoning_effort, Gemini/Vertex AI thinking budgets, Bedrock's Claude thinking field). Azure, Mistral, Cohere, and OCI have no documented per-call toggle and raise ProviderNotFoundError rather than silently ignoring it - see the Providers page for the full support matrix.

response = anyask.ask(
    "What's 17 * 24?", provider="anthropic", model="claude-opus-4-8", reasoning=True,
)

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.).

CLI

A small anyask console script installs alongside the Python API - it doesn't call any provider, it only checks readiness (SDK installed, credentials resolve) without making a network call:

anyask --version
anyask check anthropic                    # exit 0/1
anyask check bedrock --region us-east-1
anyask ready                              # sweep every provider (always exits 0)

See the CLI Guide for the full command reference.

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.2.0.tar.gz (27.8 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.2.0-py3-none-any.whl (39.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for anyask-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8ec0a69d463e36dc1fe7b1bc10108d165373eeade03db59f1efafc4bd140029e
MD5 268999e1088fcefbb952ffe22f750a48
BLAKE2b-256 d04848a1cab3eee1ac0b66bb5b6bf7ef8e4b4c6a3c55d630995c2a5bfadd8efe

See more details on using hashes here.

Provenance

The following attestation bundles were made for anyask-0.2.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.2.0-py3-none-any.whl.

File metadata

  • Download URL: anyask-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 39.8 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93679e33ac46bb730cccfb2ef9024768b875e4c89e39c38478b66d9d6263f5e4
MD5 f8942e7f1b9d07e1aa2a171b566ae579
BLAKE2b-256 0ed003e417fbe81e5bf12cda21f38ef2522f9b3c3e4b2f54cbd6e0535b108ec7

See more details on using hashes here.

Provenance

The following attestation bundles were made for anyask-0.2.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