Skip to content

API Reference parrot.clients.local.client

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.clients.local.client

View source

LocalLLM client for AI-Parrot.

Extends OpenAIBaseClient (FEAT-438) to support local/self-hosted OpenAI-compatible LLM servers such as Ollama, vLLM, llama.cpp, and LM Studio.

Alias CompletionUsage

Re-exported from parrot.models.CompletionUsage.

Alias InvokeError

Re-exported from parrot.exceptions.InvokeError.

Alias InvokeResult

Re-exported from parrot.models.responses.InvokeResult.

Class LocalLLMClient

Client for local/self-hosted OpenAI-compatible LLM servers.

Extends OpenAIBaseClient (FEAT-438) with local-server-friendly defaults:

  • No API key required (optional)
  • Configurable base_url (defaults to vLLM's http://localhost:8000/v1)
  • Higher timeout (120s vs 60s for cloud)
  • Responses API disabled (local servers don't support it)
  • Relaxed structured output model guard

Supports Ollama, vLLM, llama.cpp, LM Studio, and any server that exposes an OpenAI-compatible /v1 API.

Parameter Type Default Description
api_key Optional[str] None Optional API key. Defaults to None (most local servers don't require authentication). Falls back to LOCAL_LLM_API_KEY env var.
base_url Optional[str] None Base URL of the local server. Defaults to http://localhost:8000/v1. Falls back to LOCAL_LLM_BASE_URL env var.
model Optional[str] None Default model to use. Falls back to LOCAL_LLM_MODEL env var, then llama3.1:8b.
**kwargs {} Additional arguments passed to OpenAIBaseClient.

Attributes:

Attribute Type Description
client_type str
client_name str
provider_keys tuple[str, ...]
models type[Enum]
model str

Method LocalLLMClient.get_client

Initialize AsyncOpenAI with local server URL.

Uses "no-key" as a placeholder when no API key is provided, since some servers require a non-empty bearer token.

get_client() -> 'AsyncOpenAI'

Returns: 'AsyncOpenAI' — AsyncOpenAI client configured for the local server.

Method LocalLLMClient.ask

Ask the local LLM a question.

Overrides OpenAIBaseClient.ask() to use the local default model and skip structured output model guards.

ask(prompt: str, model: Union[str, LocalLLMModel] = None, **kwargs)

Parameter Type Default Description
prompt str The prompt to send to the model.
model Union[str, LocalLLMModel] None Model to use. Defaults to the client's configured model.
**kwargs {} Additional arguments passed to OpenAIBaseClient.ask().

Method LocalLLMClient.ask_stream

Stream the local LLM's response.

Overrides OpenAIBaseClient.ask_stream() to use the local default model.

ask_stream(prompt: str, model: Union[str, LocalLLMModel] = None, **kwargs)

Parameter Type Default Description
prompt str The prompt to send to the model.
model Union[str, LocalLLMModel] None Model to use. Defaults to the client's configured model.
**kwargs {} Additional arguments passed to OpenAIBaseClient.ask_stream().

Method LocalLLMClient.list_models

List models available on the local server.

Queries the server's /v1/models endpoint via the OpenAI SDK.

list_models() -> List[str]

Returns: List[str] — List of model ID strings available on the server.

Raises:

  • Exception — If the server is unreachable or returns an error.

Method LocalLLMClient.health_check

Check if the local server is reachable.

Attempts to list models as a connectivity test.

health_check() -> bool

Returns: bool — True if the server responds, False otherwise.

Method LocalLLMClient.invoke

Lightweight stateless invocation for LocalLLMClient.

Attempts native OpenAI-compatible json_schema response_format for structured output. If the local server rejects response_format (e.g., vLLM with older models), falls back to schema-in-system-prompt (same strategy as AnthropicClient).

_lightweight_model is None so the model falls back to self.model — the user controls which local model to deploy.

invoke(prompt: str, *, output_type: Optional[type] = None, structured_output: Optional[StructuredOutputConfig] = None, model: Optional[str] = None, system_prompt: Optional[str] = None, max_tokens: Optional[int] = None, temperature: float = 0.0, use_tools: bool = False, tools: Optional[list] = None) -> InvokeResult

Parameter Type Default Description
prompt str User prompt.
output_type Optional[type] None Pydantic model or dataclass to parse the response into.
structured_output Optional[StructuredOutputConfig] None Full :class:StructuredOutputConfig; takes precedence over output_type.
model Optional[str] None Model override. Falls back to self.model.
system_prompt Optional[str] None System prompt override.
max_tokens Optional[int] None Maximum completion tokens.
temperature float 0.0 Sampling temperature.
use_tools bool False Whether to inject registered tools.
tools Optional[list] None Additional tool definitions.

Returns: InvokeResult — class:InvokeResult with parsed output.

Raises:

  • `` — class:InvokeError: On provider errors.

Alias LocalLLMModel

Re-exported from parrot.clients.local.models.LocalLLMModel.

Alias OpenAIBaseClient

Re-exported from parrot.clients.openai_base.OpenAIBaseClient.

Alias StructuredOutputConfig

Re-exported from parrot.models.StructuredOutputConfig.

Attribute logger

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally