semantica.llms provides a consistent generation API across major LLM providers and a separate typed-decision API for TypeSafe Jev:
  • Generative providers are interchangeable wherever a provider instance is taken: the llm_provider= argument of AgentContext.query_with_reasoning(), ContextRetriever.query_with_reasoning() and TemporalQueryRewriter
  • Extractors take no instance: they build the provider themselves from provider=, llm_model= and api_key=
  • LiteLLM routes to 100+ providers with a single class and model-string prefixes
  • HuggingFaceLLM runs fully on-premise: no API key, no network calls
  • Structured output via generate_typed() for schema-validated extraction
  • Jev and AsyncJev return Choice, Noul, or Score decisions without pretending to generate text
  • Streaming, tool use, and generate_batch() for bulk inference

Exported Classes

Anthropic, Gemini, Ollama, DeepSeek, Azure, Bedrock, Cohere, and 90+ others are all available via LiteLLM using their model-string prefix. See the LiteLLM section below.

What You Get

  • Unified LLMProvider interface: swap providers with a one-line change, no application code changes
  • LiteLLM: single class for 100+ providers using model-string routing
  • Local models: HuggingFaceLLM runs fully on-premise, no API key
  • Typed decisions: Jev supports bounded Choice, Noul, and Score decisions with probability metadata
  • Streaming: token-by-token output for low-latency UX
  • Custom gateways: point OpenAI at any OpenAI-compatible endpoint via base_url

Choosing a Provider

Free tier, fastest inference, zero setup friction. Best for development and high-throughput extraction pipelines.
Get your free key at console.groq.com.

API Key Setup

Configuration File Method

Programmatic Setup

Security Best Practices

Never commit API keys to version control. Use environment variables or secure secret management.

TypeSafe Jev

Jev and AsyncJev wrap the official typesafe-sdk System One client. They are decision-only providers: neither class implements generate(), generate_structured(), or generate_typed(), and neither can stand in for a generative provider: not as the llm_provider= argument of a reasoning query, and not as provider= in an extractor.
Jev is experimental and early-access. The llm-typesafe extra currently supports the reviewed TypeSafe SDK 0.7 API. Like Semantica itself, it requires Python 3.11 or newer; the SDK is optional and guarded, so the base installation does not need it.
TypeSafe SDK 0.7 emits full request and response bodies through its typesafe_sdk logger at DEBUG; authorization headers are redacted, but application state is not. Keep that logger at INFO or higher when state may be sensitive, even if the root logger uses DEBUG.

Constructors

Methods

state accepts a string, mapping, or list. question is the instruction evaluated against that state. Inputs by kind:
  • kind="choice": pass choices as a sequence of labels or a label-to-description mapping. criteria= is accepted as an equivalent explicit name. Do not pass both.
  • kind="noul": optionally pass criteria={"true": ..., "false": ...}.
  • kind="score": pass criteria as an ordered sequence of rubric levels, beginning at score zero.
Additional request options are forwarded to system_one(), such as per-call model, retry, timeout, extra_headers, or extra_body.

JevDecisionResult

result.to_dict() returns a serializable copy suitable for Semantica decision metadata or cross_system_context. It deliberately retains the raw Noul probability separately from the derived confidence.

Providers

LiteLLM: 100+ Providers

LiteLLM is the recommended way to access any provider not directly exported by semantica.llms. Use the provider/model string format:
The full list of supported LiteLLM model strings is at docs.litellm.ai/docs/providers. Use the provider/model format shown above.

Custom / Enterprise Gateways

Any OpenAI-compatible endpoint: internal routing layers, Qwen proxies, or private LLaMA deployments:
base_url is validated at construction time. Non-HTTP(S) schemes raise ValueError to prevent SSRF attacks (fixed in v0.5.0).

Using Generative Providers in Extractors

Extractors do not take a provider instance. They build one themselves from keyword configuration: provider names the backend (default "openai"), llm_model picks the model, and api_key is read from the matching <PROVIDER>_API_KEY variable when it is omitted. llm_provider= is not read here: it travels through **config into the provider factory and is kept in the constructed provider’s config mapping, which nothing consults — the instance never serves as the extractor’s provider, so the extractor runs against the backend named by provider= (the "openai" default when it is omitted). Jev is not usable here either, because it returns decisions rather than generated text:
Use llm_model, not model. Both names configure an extractor’s own LLM call (llm_model wins), but TripletExtractor strips model out of the configuration it shares with the entity and relation extractors it builds internally, because there that keyword is the spaCy/HuggingFace model name. So model alone reaches the triplet stage only, and the two internal stages are built with no LLM model at all: they are constructed with an explicit model=None, which overrides the provider’s own default. llm_model configures all three.

Provider Comparison

For production extraction pipelines, Groq delivers the best throughput-to-cost ratio. For complex multi-hop reasoning, Claude Opus or GPT-4o provide the highest accuracy.

Defaults and Reproducibility

Documentation examples may showcase stronger models for better developer experience, while implementation defaults prioritize reliability and cost efficiency. Understanding actual defaults helps with reproducible results and consistent benchmarking. Verified Implementation Defaults: These are the models used when you construct a provider without specifying model=. Examples throughout this documentation use stronger showcase models. Always pass model= explicitly in production for reproducible results. Why This Matters:
  • Reproducible extraction results across environments
  • Consistent baseline performance for benchmarking
  • Predictable costs when scaling production workloads

Performance and Reliability Tips

Extraction with Retries

Model Selection by Use Case

Error Handling

  • Semantic Extract — Use LLMs for NER and relation extraction.
  • Agno Integration — LLM providers in Agno multi-agent teams.
  • Reasoning — LLM-backed deductive and abductive reasoning.
  • Context — GraphRAG uses LLMs for reasoning over knowledge graphs.