Skip to content

Commit

Permalink
update documentation on authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
knowsuchagency committed Nov 28, 2024
1 parent a93687e commit 6cd363e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,44 @@ def persistent_chat(message):
"""Chat: {message}"""
```

### Authentication

Authentication can be handled in two ways:

1. Directly via the `api_key` parameter:
```python
from promptic import llm

@llm(model="gpt-4o-mini", api_key="your-api-key-here")
def my_function(text):
"""Process this text: {text}"""
```

2. Through environment variables (recommended):
```bash
# OpenAI
export OPENAI_API_KEY=sk-...

# Anthropic
export ANTHROPIC_API_KEY=sk-ant-...

# Google
export GEMINI_API_KEY=...

# Azure OpenAI
export AZURE_API_KEY=...
export AZURE_API_BASE=...
export AZURE_API_VERSION=...
```

The supported environment variables correspond to the model provider:

| Provider | Environment Variable | Model Examples |
|----------|---------------------|----------------|
| OpenAI | `OPENAI_API_KEY` | gpt-4o, gpt-3.5-turbo |
| Anthropic | `ANTHROPIC_API_KEY` | claude-3-haiku-20240307, claude-3-opus-20240229, claude-3-sonnet-20240229 |
| Google | `GEMINI_API_KEY` | gemini/gemini-1.5-pro-latest |

## API Reference

### `llm`
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies = [
"litellm~=1.38",
"pydantic~=2.7",
]
version = "2.1.4"
version = "2.1.5"
readme = "README.md"
requires-python = ">=3.11"

Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6cd363e

Please sign in to comment.