orxtra v0.13.0 /services.src.orxtra.services._ask
On this page

One-shot LLM convenience functions, no PG or scheduler involved: ask() sends a single prompt, ask_structured() validates the reply against a JSON schema, sync_ask() wraps it for non-async callers.

#services.src.orxtra.services._ask

#services.src.orxtra.services._ask

#_build_transport

python
def _build_transport(provider_type: str, api_key: str, *, base_url: str | None=None, max_tokens: int=4096) -> Transport

Construct a Transport from provider parameters.

#ask

python
async def ask(prompt: str, provider_type: str, model: str, api_key: str, *, system_prompt: str | None=None, base_url: str | None=None, max_tokens: int=4096) -> str

Send a prompt to an LLM and get text back.

No PG, no scheduler, no workflows. A one-shot convenience function that constructs a provider, sends a single message, and returns the result text.

#ask_structured

python
async def ask_structured(prompt: str, provider_type: str, model: str, api_key: str, schema: dict[str, Any], *, system_prompt: str | None=None, base_url: str | None=None, max_tokens: int=4096) -> dict[str, Any]

Send a prompt and get a JSON-validated response.

Wraps ask() with a system prompt instructing the LLM to respond with JSON matching the given schema, then parses and validates the response.

#sync_ask

python
def sync_ask(prompt: str, provider_type: str, model: str, api_key: str, **kwargs: Any) -> str

Synchronous wrapper around :func:ask.

Constructs a provider, sends a single message, and returns the result text. Intended for scripts and synchronous consumers that cannot use async/await.

Search