diff --git a/docs/static/img/api-key-generation.png b/docs/static/img/api-key-generation.png new file mode 100644 index 0000000000..7506076401 Binary files /dev/null and b/docs/static/img/api-key-generation.png differ diff --git a/docs/static/img/docs/api-key-generation.png b/docs/static/img/docs/api-key-generation.png deleted file mode 100644 index 713a4a79d4..0000000000 Binary files a/docs/static/img/docs/api-key-generation.png and /dev/null differ diff --git a/docs/usage/cloud/cloud-api.mdx b/docs/usage/cloud/cloud-api.mdx index c4565cccaa..12438a6b70 100644 --- a/docs/usage/cloud/cloud-api.mdx +++ b/docs/usage/cloud/cloud-api.mdx @@ -1,9 +1,11 @@ --- title: Cloud API -description: OpenHands Cloud provides a REST API that allows you to programmatically interact with the service. This guide explains how to obtain an API key and use the API to start conversations. +description: OpenHands Cloud provides a REST API that allows you to programmatically interact with OpenHands. + This guide explains how to obtain an API key and use the API to start conversations and retrieve their status. --- -For more detailed information about the API, refer to the [OpenHands API Reference](https://docs.all-hands.dev/swagger-ui/). +For the available API endpoints, refer to the +[OpenHands API Reference](https://docs.all-hands.dev/api-reference). ## Obtaining an API Key @@ -16,7 +18,7 @@ To use the OpenHands Cloud API, you'll need to generate an API key: 5. Give your key a descriptive name (Example: "Development" or "Production") and select `Create`. 6. Copy the generated API key and store it securely. It will only be shown once. -![API Key Generation](/static/img/docs/api-key-generation.png) +![API Key Generation](/static/img/api-key-generation.png) ## API Usage @@ -33,87 +35,81 @@ To start a new conversation with OpenHands to perform a task, you'll need to mak #### Examples -
-cURL -```bash -curl -X POST "https://app.all-hands.dev/api/conversations" \ - -H "Authorization: Bearer YOUR_API_KEY" \ - -H "Content-Type: application/json" \ - -d '{ - "initial_user_msg": "Check whether there is any incorrect information in the README.md file and send a PR to fix it if so.", - "repository": "yourusername/your-repo" - }' -``` -
+ + ```bash + curl -X POST "https://app.all-hands.dev/api/conversations" \ + -H "Authorization: Bearer YOUR_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "initial_user_msg": "Check whether there is any incorrect information in the README.md file and send a PR to fix it if so.", + "repository": "yourusername/your-repo" + }' + ``` + -
-Python (with requests) + + ```python + import requests -```python -import requests + api_key = "YOUR_API_KEY" + url = "https://app.all-hands.dev/api/conversations" -api_key = "YOUR_API_KEY" -url = "https://app.all-hands.dev/api/conversations" - -headers = { - "Authorization": f"Bearer {api_key}", - "Content-Type": "application/json" -} - -data = { - "initial_user_msg": "Check whether there is any incorrect information in the README.md file and send a PR to fix it if so.", - "repository": "yourusername/your-repo" -} - -response = requests.post(url, headers=headers, json=data) -conversation = response.json() - -print(f"Conversation Link: https://app.all-hands.dev/conversations/{conversation['conversation_id']}") -print(f"Status: {conversation['status']}") -``` -
- -
-TypeScript/JavaScript (with fetch) - -```typescript -const apiKey = "YOUR_API_KEY"; -const url = "https://app.all-hands.dev/api/conversations"; - -const headers = { - "Authorization": `Bearer ${apiKey}`, - "Content-Type": "application/json" -}; - -const data = { - initial_user_msg: "Check whether there is any incorrect information in the README.md file and send a PR to fix it if so.", - repository: "yourusername/your-repo" -}; - -async function startConversation() { - try { - const response = await fetch(url, { - method: "POST", - headers: headers, - body: JSON.stringify(data) - }); - - const conversation = await response.json(); - - console.log(`Conversation Link: https://app.all-hands.dev/conversations/${conversation.id}`); - console.log(`Status: ${conversation.status}`); - - return conversation; - } catch (error) { - console.error("Error starting conversation:", error); + headers = { + "Authorization": f"Bearer {api_key}", + "Content-Type": "application/json" } -} -startConversation(); -``` + data = { + "initial_user_msg": "Check whether there is any incorrect information in the README.md file and send a PR to fix it if so.", + "repository": "yourusername/your-repo" + } -
+ response = requests.post(url, headers=headers, json=data) + conversation = response.json() + + print(f"Conversation Link: https://app.all-hands.dev/conversations/{conversation['conversation_id']}") + print(f"Status: {conversation['status']}") + ``` + + + + ```typescript + const apiKey = "YOUR_API_KEY"; + const url = "https://app.all-hands.dev/api/conversations"; + + const headers = { + "Authorization": `Bearer ${apiKey}`, + "Content-Type": "application/json" + }; + + const data = { + initial_user_msg: "Check whether there is any incorrect information in the README.md file and send a PR to fix it if so.", + repository: "yourusername/your-repo" + }; + + async function startConversation() { + try { + const response = await fetch(url, { + method: "POST", + headers: headers, + body: JSON.stringify(data) + }); + + const conversation = await response.json(); + + console.log(`Conversation Link: https://app.all-hands.dev/conversations/${conversation.id}`); + console.log(`Status: ${conversation.status}`); + + return conversation; + } catch (error) { + console.error("Error starting conversation:", error); + } + } + + startConversation(); + ``` + #### Response @@ -145,14 +141,12 @@ GET https://app.all-hands.dev/api/conversations/{conversation_id} #### Example -
-cURL - -```bash -curl -X GET "https://app.all-hands.dev/api/conversations/{conversation_id}" \ - -H "Authorization: Bearer YOUR_API_KEY" -``` -
+ + ```bash + curl -X GET "https://app.all-hands.dev/api/conversations/{conversation_id}" \ + -H "Authorization: Bearer YOUR_API_KEY" + ``` + #### Response diff --git a/docs/usage/installation.mdx b/docs/usage/installation.mdx index 8e0ab99619..7d4f7a9af5 100644 --- a/docs/usage/installation.mdx +++ b/docs/usage/installation.mdx @@ -12,7 +12,7 @@ To get started with OpenHands Cloud, visit [app.all-hands.dev](https://app.all-h For more information see [getting started with OpenHands Cloud.](/usage/cloud/openhands-cloud) -## Running OpenHands Locally +## Running OpenHands on Your Own Run OpenHands on your local system and bring your own LLM and API key. diff --git a/docs/usage/local-setup.mdx b/docs/usage/local-setup.mdx index f059273cac..a3f5550efb 100644 --- a/docs/usage/local-setup.mdx +++ b/docs/usage/local-setup.mdx @@ -62,17 +62,17 @@ A system with a modern processor and a minimum of **4GB RAM** is recommended to ### Start the App ```bash -docker pull docker.all-hands.dev/all-hands-ai/runtime:0.40-nikolaik +docker pull docker.all-hands.dev/all-hands-ai/runtime:0.41-nikolaik docker run -it --rm --pull=always \ - -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.40-nikolaik \ + -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.41-nikolaik \ -e LOG_ALL_EVENTS=true \ -v /var/run/docker.sock:/var/run/docker.sock \ -v ~/.openhands-state:/.openhands-state \ -p 3000:3000 \ --add-host host.docker.internal:host-gateway \ --name openhands-app \ - docker.all-hands.dev/all-hands-ai/openhands:0.40 + docker.all-hands.dev/all-hands-ai/openhands:0.41 ``` You'll find OpenHands running at http://localhost:3000!