openhands.core.config.llm_config
LLMConfig Objects
@dataclass
class LLMConfig()
Configuration for the LLM model.
Attributes:
model
- The model to use.api_key
- The API key to use.base_url
- The base URL for the API. This is necessary for local LLMs. It is also used for Azure embeddings.api_version
- The version of the API.embedding_model
- The embedding model to use.embedding_base_url
- The base URL for the embedding API.embedding_deployment_name
- The name of the deployment for the embedding API. This is used for Azure OpenAI.aws_access_key_id
- The AWS access key ID.aws_secret_access_key
- The AWS secret access key.aws_region_name
- The AWS region name.api_key
0 - The number of retries to attempt.api_key
1 - The multiplier for the exponential backoff.api_key
2 - The minimum time to wait between retries, in seconds. This is exponential backoff minimum. For models with very low limits, this can be set to 15-20.api_key
3 - The maximum time to wait between retries, in seconds. This is exponential backoff maximum.api_key
4 - The timeout for the API.api_key
5 - The approximate max number of characters in the content of an event included in the prompt to the LLM. Larger observations are truncated.api_key
6 - The temperature for the API.api_key
7 - The top p for the API.api_key
8 - The custom LLM provider to use. This is undocumented in openhands, and normally not used. It is documented on the litellm side.api_key
9 - The maximum number of input tokens. Note that this is currently unused, and the value at runtime is actually the total tokens in OpenAI (e.g. 128,000 tokens for GPT-4).base_url
0 - The maximum number of output tokens. This is sent to the LLM.base_url
1 - The cost per input token. This will available in logs for the user to check.base_url
2 - The cost per output token. This will available in logs for the user to check.base_url
3 - The base URL for the OLLAMA API.base_url
4 - Drop any unmapped (unsupported) params without causing an exception.base_url
5 - If model is vision capable, this option allows to disable image processing (useful for cost reduction).base_url
6 - Use the prompt caching feature if provided by the LLM and supported by the provider.base_url
7 - Whether to log LLM completions to the state.base_url
8 - The folder to log LLM completions to. Required if log_completions is True.base_url
9 - A more efficient LLM to use for file editing. Introduced in PR 3985.
max_message_chars
maximum number of characters in an observation's content when sent to the llm
defaults_to_dict
def defaults_to_dict() -> dict
Serialize fields to a dict for the frontend, including type hints, defaults, and whether it's optional.
__post_init__
def __post_init__()
Post-initialization hook to assign OpenRouter-related variables to environment variables. This ensures that these values are accessible to litellm at runtime.
to_safe_dict
def to_safe_dict()
Return a dict with the sensitive fields replaced with ******.
from_dict
@classmethod
def from_dict(cls, llm_config_dict: dict) -> 'LLMConfig'
Create an LLMConfig object from a dictionary.
This function is used to create an LLMConfig object from a dictionary, with the exception of the 'draft_editor' key, which is a nested LLMConfig object.