OpenRouterModelConfig
Base classes¶
| Name | Children | Inherits |
|---|---|---|
| BaseModelConfig llmling_models_config.configs Base for model configurations. |
â‹” Inheritance diagram¶
graph TD
3496673408["configs.OpenRouterModelConfig"]
3497727833["configs.BaseModelConfig"]
330168112["schema.Schema"]
3879467795["main.BaseModel"]
2751680898["builtins.object"]
3497727833 --> 3496673408
330168112 --> 3497727833
3879467795 --> 330168112
2751680898 --> 3879467795
🛈 DocStrings¶
Bases: BaseModelConfig
Configuration for OpenRouter models.
OpenRouter provides access to many models through a unified API.
Source code in src/llmling_models_config/configs.py
867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 | |
extra_headers
class-attribute
instance-attribute
¶
extra_headers: dict[str, str] | None = Field(
default=None, examples=[{"Custom-Header": "value"}], title="Extra headers"
)
Extra headers to send to the model.
frequency_penalty
class-attribute
instance-attribute
¶
frequency_penalty: float | None = Field(
default=None, ge=-2.0, le=2.0, examples=[-1.0, 0.0, 0.5, 1.0], title="Frequency penalty"
)
Penalize new tokens based on their existing frequency in the text so far.
identifier
class-attribute
instance-attribute
¶
identifier: OpenrouterModelName | str = Field(
examples=["anthropic/claude-3.5-sonnet", "openai/gpt-4-turbo"], title="Model identifier"
)
String identifier for the model.
max_tokens
class-attribute
instance-attribute
¶
max_tokens: int | None = Field(
default=None, ge=1, examples=[1024, 2048, 4096], title="Maximum tokens"
)
The maximum number of tokens to generate before stopping.
models
class-attribute
instance-attribute
¶
models: list[str] | None = Field(
default=None, title="Fallback models", examples=[["anthropic/claude-3-sonnet", "openai/gpt-4"]]
)
List of fallback models to try if the primary model fails.
presence_penalty
class-attribute
instance-attribute
¶
presence_penalty: float | None = Field(
default=None, ge=-2.0, le=2.0, examples=[-1.0, 0.0, 0.5, 1.0], title="Presence penalty"
)
Penalize new tokens based on whether they have appeared in the text so far.
preset
class-attribute
instance-attribute
¶
Named preset configuration for common use cases.
provider
class-attribute
instance-attribute
¶
provider: dict[str, Any] | None = Field(
default=None,
title="Provider configuration",
examples=[
{"order": ["anthropic", "openai"], "allow_fallbacks": True},
{"only": ["anthropic"], "data_collection": "deny"},
],
)
Provider routing configuration.
Options include: - order: List of provider preferences - allow_fallbacks: Whether to allow fallback providers - require_parameters: Require providers to support all parameters - data_collection: 'allow' or 'deny' data collection - only: Restrict to specific providers - ignore: Exclude specific providers - quantizations: Preferred quantization levels - sort: Sort by 'price', 'throughput', or 'latency'
reasoning
class-attribute
instance-attribute
¶
reasoning: dict[str, Any] | None = Field(
default=None,
title="Reasoning configuration",
examples=[{"effort": "high", "max_tokens": 10000}, {"effort": "medium", "exclude": True}],
)
Reasoning/thinking configuration.
Options include: - effort: 'high', 'medium', or 'low' - max_tokens: Maximum tokens for reasoning - exclude: Whether to exclude reasoning from response - enabled: Enable/disable reasoning
seed
class-attribute
instance-attribute
¶
The random seed to use for the model.
stop_sequences
class-attribute
instance-attribute
¶
stop_sequences: list[str] | None = Field(
default=None, examples=[["STOP", "END"], ["\n\n"]], title="Stop sequences"
)
Sequences that will cause the model to stop generating.
temperature
class-attribute
instance-attribute
¶
temperature: float | None = Field(
default=None, ge=0.0, examples=[0.0, 0.7, 1.0, 2.0], title="Temperature"
)
Amount of randomness injected into the response.
timeout
class-attribute
instance-attribute
¶
Override the client-level default timeout for a request, in seconds.
top_p
class-attribute
instance-attribute
¶
top_p: float | None = Field(
default=None, ge=0.0, le=1.0, examples=[0.1, 0.9, 1.0], title="Top-p (nucleus sampling)"
)
An alternative to sampling with temperature, called nucleus sampling.
transforms
class-attribute
instance-attribute
¶
List of transforms to apply to requests.
type
class-attribute
instance-attribute
¶
Type identifier for OpenRouter model.
usage
class-attribute
instance-attribute
¶
usage: dict[str, Any] | None = Field(
default=None, title="Usage configuration", examples=[{"include": True}]
)
Usage tracking configuration.
get_model_settings
¶
Get model settings in pydantic-ai format.