Ovhcloud
OVHcloud #
Bases: OpenAI
OVHcloud AI Endpoints LLM.
OVHcloud AI Endpoints provides OpenAI-compatible API endpoints for various models. You can use the API for free with rate limits if no API key is provided or if it's an empty string. Otherwise, generate an API key from the OVHcloud manager at https://ovh.com/manager in the Public Cloud section, AI & Machine Learning, AI Endpoints.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
str
|
The model name to use (e.g., "llama-3.1-8b-instruct"). Model availability is validated dynamically against the API with fallback to static validation if the API call fails. |
required |
temperature
|
float
|
The temperature to use for generation |
DEFAULT_TEMPERATURE
|
max_tokens
|
int
|
The maximum number of tokens to generate |
DEFAULT_NUM_OUTPUTS
|
additional_kwargs
|
Optional[Dict[str, Any]]
|
Additional kwargs for the API |
None
|
max_retries
|
int
|
The maximum number of retries to make |
10
|
api_key
|
Optional[str]
|
The OVHcloud API key. If not provided or empty string, the API can be used for free with rate limits. |
None
|
callback_manager
|
Optional[CallbackManager]
|
Callback manager for logging |
None
|
default_headers
|
Optional[Dict[str, str]]
|
Default headers for API requests |
None
|
system_prompt
|
Optional[str]
|
System prompt for chat |
None
|
messages_to_prompt
|
Optional[Callable]
|
Function to format messages to prompt |
None
|
completion_to_prompt
|
Optional[Callable]
|
Function to format completion prompt |
None
|
pydantic_program_mode
|
PydanticProgramMode
|
Mode for Pydantic handling |
DEFAULT
|
output_parser
|
Optional[BaseOutputParser]
|
Parser for model outputs |
None
|
api_base
|
Optional[str]
|
Override the default API base URL |
None
|
Examples:
pip install llama-index-llms-ovhcloud
from llama_index.llms.ovhcloud import OVHcloud
# Using with API key
llm = OVHcloud(
model="llama-3.1-8b-instruct",
api_key="YOUR_API_KEY",
)
response = llm.complete("Hello, world!")
# Using without API key (free with rate limits)
llm = OVHcloud(
model="llama-3.1-8b-instruct",
api_key="", # or omit api_key parameter
)
response = llm.complete("Hello, world!")
# Get available models dynamically
llm = OVHcloud(model="llama-3.1-8b-instruct")
available = llm.available_models # List[Model] - fetched dynamically
model_ids = [model.id for model in available]
print(f"Available models: {model_ids}")
# Chat messages
from llama_index.core.llms import ChatMessage
messages = [
ChatMessage(
role="system", content="You are a helpful assistant"
),
ChatMessage(role="user", content="What is the capital of France?"),
]
response = llm.chat(messages)
print(response)
Source code in llama_index/llms/ovhcloud/base.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
available_models
property
#
available_models: List[Model]
Get available models from OVHcloud AI Endpoints.
class_name
classmethod
#
class_name() -> str
Get class name.
Source code in llama_index/llms/ovhcloud/base.py
157 158 159 160 | |
options: members: - OVHcloud AI Endpoints