Types¶
Core type definitions and data models used throughout the SDK.
types
¶
JobContext
¶
Bases: BaseModel
Source code in ivcap_service/types.py
llm_client(**kwargs)
¶
Return an OpenAI-compatible client, ready to use.
This hides the details of how/whether to route completions through a LiteLLM proxy from the service code, and resolves the API key in the following order (first match wins):
- An explicit 'api_key' kwarg passed in here.
- 'LITELLM_PROXY' environment variable - if set, 'base_url' is pointed at that proxy's '/v1' endpoint and a placeholder 'api_key' is used (the proxy itself handles authentication/authorization), so no real key is needed.
- 'OPENAI_API_KEY' environment variable - the usual variable read by a plain 'openai.OpenAI()' client ('OPENAI_BASE_URL' is used the same way for the endpoint).
- '~/.config/openai/api_key' - a plain text file containing just the key, as a local-development fallback for when you don't want to export environment variables.
If none of the above yields a key (and 'LITELLM_PROXY' isn't set, since no key is needed in that case), a 'RuntimeError' is raised with guidance on how to configure one.
Any 'kwargs' passed in are forwarded to 'openai.OpenAI(...)' and take precedence over everything above (e.g. pass 'base_url=...' to override the endpoint too).
See also 'DEFAULT_LLM_MODEL' for the default model name to pass to e.g. 'client.chat.completions.create(model=..., ...)' when the caller/request doesn't specify one.
Requires the optional 'openai' package to be installed.
Source code in ivcap_service/types.py
BinaryResult
dataclass
¶
If the result of the tool is a non json serialisable object, return an
instance of this class indicating the content-type and the actual
result either as a byte array or a file handle to a binary content (open(..., "rb"))
Source code in ivcap_service/types.py
ExecutionError
¶
Bases: BaseModel
Pydantic model for execution errors.