Skip to content

Commit 468bb0a

Browse files
authored
Add documentation for using OpenHands LLM provider with the SDK (#186)
* Add documentation for using OpenHands LLM provider with the SDK - Document how to use OpenHands API key with the SDK - Show environment variable configuration (LLM_API_KEY, LLM_MODEL) - Explain that openhands/ prefix auto-configures the base URL - Include Python code examples - List available models with openhands/ prefix - Add network requirements note for firewall restrictions * Fix gemini-3-pro-preview cached input cost to match LiteLLM DB
1 parent 194549d commit 468bb0a

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

openhands/usage/llms/openhands-llms.mdx

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,49 @@ When running OpenHands, you'll need to set the following in the OpenHands UI thr
3333
When you use OpenHands as an LLM provider in the CLI, we may collect minimal usage metadata and send it to All Hands AI. For details, see our Privacy Policy: https://openhands.dev/privacy
3434
</Note>
3535

36+
## Using OpenHands LLM Provider with the SDK
37+
38+
You can use your OpenHands API key with the [OpenHands SDK](https://docs.openhands.dev/sdk) to build custom agents and automation pipelines.
39+
40+
### Configuration
41+
42+
The SDK automatically configures the correct API endpoint when you use the `openhands/` model prefix. Simply set two environment variables:
43+
44+
```bash
45+
export LLM_API_KEY="your-openhands-api-key"
46+
export LLM_MODEL="openhands/claude-sonnet-4-20250514"
47+
```
48+
49+
### Example
50+
51+
```python
52+
from openhands.sdk import LLM
53+
54+
# The openhands/ prefix auto-configures the base URL
55+
llm = LLM.load_from_env()
56+
57+
# Or configure directly
58+
llm = LLM(
59+
model="openhands/claude-sonnet-4-20250514",
60+
api_key="your-openhands-api-key",
61+
)
62+
```
63+
64+
The `openhands/` prefix tells the SDK to automatically route requests to the OpenHands LLM proxy—no need to manually set a base URL.
65+
66+
### Available Models
67+
68+
When using the SDK, prefix any model from the pricing table below with `openhands/`:
69+
- `openhands/claude-sonnet-4-20250514`
70+
- `openhands/claude-sonnet-4-5-20250929`
71+
- `openhands/claude-opus-4-20250514`
72+
- `openhands/gpt-5-2025-08-07`
73+
- etc.
74+
75+
<Note>
76+
If your network has firewall restrictions, ensure the `all-hands.dev` domain is allowed. The SDK connects to `llm-proxy.app.all-hands.dev`.
77+
</Note>
78+
3679
## Pricing
3780

3881
Pricing follows official API provider rates. Below are the current pricing details for OpenHands models:
@@ -52,7 +95,7 @@ Pricing follows official API provider rates. Below are the current pricing detai
5295
| devstral-small-2507 | $0.10 | N/A | $0.30 | 128,000 | 128,000 |
5396
| o3 | $2.00 | $0.50 | $8.00 | 200,000 | 100,000 |
5497
| o4-mini | $1.10 | $0.275 | $4.40 | 200,000 | 100,000 |
55-
| gemini-3-pro-preview | $2.00 | $0.125 | $12.00 | 1,048,576 | 65,535 |
98+
| gemini-3-pro-preview | $2.00 | $0.20 | $12.00 | 1,048,576 | 65,535 |
5699
| kimi-k2-0711-preview | $0.60 | $0.15 | $2.50 | 131,072 | 131,072 |
57100
| qwen3-coder-480b | $0.40 | N/A | $1.60 | N/A | N/A |
58101

0 commit comments

Comments
 (0)