Claude AI provides an API for developers to use the advanced AI in their own tools. Our tutorial shows how to set up the Claude API and use the Computer Use feature.
What can the API for Claude do?
With the Antropic API, you can integrate the powerful Claude AI into your own tools using code. In addition, tools such as Flowise and Langflow (see article) allow you to develop your own AI workflows with Claude without coding. The Antropic API also gives you access to other features that cannot yet be used via the Claude interface (e.g. computer use for desktop control)
Potential: What can the Computer Use feature do?
Via the Anthropic API, you can also use the “Computer Use API”, with which the AI can control the desktop and thus all programs (see article: Claude Computer Use Capability). This enables completely new types of automation by AI:
- Automate processes (similar to what is possible with RPA tools, and in every possible tool)
- Automate data entry (saves time)
- Automate QA and tests (similar to Selenium)
- Technical PC support (imagine an AI support agent that sets up, troubleshoots and helps your computer)
- Automate any desktop activity (e.g. creating files, filing and more)
Tutorial: Set up the Anthropic API console
To use Claude via API, you need to register for the API console, enter your payment details, top up a few credits and click to create an API key. The process takes no longer than 5 minutes.
Step 1: Register for the API console
To use Claude via API, register for the Anthopic API console.
After registering, you have access to the Workbench (a kind of playground for trying out prompts and Claude models) and can create API keys.
Step 2: Enter payment data
To use the API, you must enter your payment details in the“Billing” menu item. You can then top up a few credits for using the API. You will need a valid credit card. The minimum amount is a one-off charge of 5 dollars. Optionally, you can activate an automatic top-up if you want to use the API more intensively and without interruption. In our test, the top-up even took place without any waiting time, so you can get started straight away.
Step 3: Create API key
Now click to create a workspace (e.g. for each project) and an API key in it, which you can then use in your own code. To the API console: Create API key
Step 4: Test Anthropic API
Once set up, we test the API. To do this, call up a terminal on the computer and execute a curl command.
curl is a standard tool for executing requests directly in the terminal. It is already pre-installed on Windows. On MacOS, it can simply be installed via the package manager homebrew(install curl).
We then execute this curl command to call the Anthropic API and replace the $ANTHROPIC_API_KEY variable with the previously generated API key. Tip for easier testing: Copy the code into a shell file, set the rights (chmod 755 myfile.sh), replace the API key there and execute the code.
Result: Successful Anthropic API call with Claude model
As a return we receive a JSON object in which Claude 3.5 Sonnet responds in the JSON part “content”. We have thus successfully set up the API and can now work with it.
Documentation:
Tips and hints:
- To register with the Claude API, you can use the same email address as for normal use of Claude
- If you do not have any credits topped up, you will receive the following error message when using the API: “Your credit balance is too low to access the Anthropic API. Please go to Plans & Billing to upgrade or purchase credits.”
Bonus tutorial: How to use the Computer Use feature from Claude
To use the Computer Use feature, you need access to the Claude API as described above. You can then use the Computer Use feature via the Claude API using the console or code (Python or Typescript).
For a simple test of the Computer Use API, run the curl script from the API documentation in the terminal. Claude is given the following task: “Save a picture of a cat to my desktop”
Result: Claude uses the Computer Use API
The Anthropic API responds by creating a plan for the task: “I’ll help you search for and save a cat picture. I’ll need to take several steps:\n\n1. First, let me take a screenshot to see the desktop”
Further steps are now required to enable Claude to take screenshots of the desktop, perform actions based on them, such as clicks, and then launch a browser and complete the task. As these tasks should be executed in a secure sandbox environment, Anthropic has even provided a test environment for this via GitHub, which can be installed via a Docker container.
Github: Anthropic Computer Use Demo:
API documentation for Computer Use (beta):
For inspiration:
Here’s a quick run-through of how Computer Use works
Good luck setting up and testing
We look forward to seeing how the powerful Claude feature is used in your own applications