mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +00:00
docs: Adds Gemini example to OpenAI-compat section (#2915)
Some checks failed
Notify Downstream / notify-downstream (push) Has been cancelled
Some checks failed
Notify Downstream / notify-downstream (push) Has been cancelled
This commit is contained in:
@@ -117,18 +117,27 @@ You can connect to OpenAI-compatible LLMs using either environment variables or
|
|||||||
<Tabs>
|
<Tabs>
|
||||||
<Tab title="Using Environment Variables">
|
<Tab title="Using Environment Variables">
|
||||||
<CodeGroup>
|
<CodeGroup>
|
||||||
```python Code
|
```python Generic
|
||||||
import os
|
import os
|
||||||
|
|
||||||
os.environ["OPENAI_API_KEY"] = "your-api-key"
|
os.environ["OPENAI_API_KEY"] = "your-api-key"
|
||||||
os.environ["OPENAI_API_BASE"] = "https://api.your-provider.com/v1"
|
os.environ["OPENAI_API_BASE"] = "https://api.your-provider.com/v1"
|
||||||
os.environ["OPENAI_MODEL_NAME"] = "your-model-name"
|
os.environ["OPENAI_MODEL_NAME"] = "your-model-name"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```python Google
|
||||||
|
import os
|
||||||
|
|
||||||
|
# Example using Gemini's OpenAI-compatible API.
|
||||||
|
os.environ["OPENAI_API_KEY"] = "your-gemini-key" # Should start with AIza...
|
||||||
|
os.environ["OPENAI_API_BASE"] = "https://generativelanguage.googleapis.com/v1beta/openai/"
|
||||||
|
os.environ["OPENAI_MODEL_NAME"] = "openai/gemini-2.0-flash" # Add your Gemini model here, under openai/
|
||||||
|
```
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
</Tab>
|
</Tab>
|
||||||
<Tab title="Using LLM Class Attributes">
|
<Tab title="Using LLM Class Attributes">
|
||||||
<CodeGroup>
|
<CodeGroup>
|
||||||
```python Code
|
```python Generic
|
||||||
llm = LLM(
|
llm = LLM(
|
||||||
model="custom-model-name",
|
model="custom-model-name",
|
||||||
api_key="your-api-key",
|
api_key="your-api-key",
|
||||||
@@ -136,6 +145,16 @@ You can connect to OpenAI-compatible LLMs using either environment variables or
|
|||||||
)
|
)
|
||||||
agent = Agent(llm=llm, ...)
|
agent = Agent(llm=llm, ...)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```python Google
|
||||||
|
# Example using Gemini's OpenAI-compatible API
|
||||||
|
llm = LLM(
|
||||||
|
model="openai/gemini-2.0-flash",
|
||||||
|
base_url="https://generativelanguage.googleapis.com/v1beta/openai/",
|
||||||
|
api_key="your-gemini-key", # Should start with AIza...
|
||||||
|
)
|
||||||
|
agent = Agent(llm=llm, ...)
|
||||||
|
```
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
</Tab>
|
</Tab>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|||||||
Reference in New Issue
Block a user