Claude 3 is the latest generation of large language models (LLMs) developed by Anthropic, first released on March 14, 2024. This model family consists of three editions: Claude 3 Haiku, Claude 3 Sonnet, and Claude 3 Opus. Each edition offers different levels of intelligence, speed, and cost-effectiveness. These models are designed to perform tasks such as analysis, forecasting, content creation, code generation, and multilingual conversations.
According to benchmarks shared by Anthropic, Claude 3 Opus beats its main competitor, OpenAI GPT-4, on several important metrics, including MMLU, GPQA, GSM8K, MGSM, and HumanEval (0-shot).
Claude 3 models are integrated into the Claude API, accessible in 159 countries, and also as part of the Amazon Bedrock service.
Users can chat with Claude 3 for free here.
This is part of a series of articles about Anthropic Claude
Claude 3 models provide the following key capabilities:
Here’s an overview of the Claude 3 model editions:
Claude 3 Haiku is the fastest and most compact model in the Claude 3 family. Designed for near-instant responsiveness, it is optimized for tasks requiring quick turnarounds and seamless AI experiences that mimic human interactions. Haiku can process dense information, such as research papers with charts and graphs, in less than three seconds.
This model is particularly suited for applications that prioritize speed and cost-effectiveness, including real-time data extraction, auto-completions, and rapid customer interactions. Haiku's compact design ensures performance without compromising on the quality of responses.
Claude 3 Sonnet strikes a balance between intelligence and speed. It is designed to handle enterprise workloads and scaled AI deployments efficiently. Sonnet offers twice the speed of its predecessors, Claude 2 and 2.1, making it suitable for rapid-response tasks such as knowledge retrieval and sales automation.
Its enhanced intelligence allows it to handle open-ended conversations, collaborate on ideas, and perform coding tasks. Sonnet can meet the needs of enterprises, providing reliable and quick responses across a range of applications.
Claude 3 Opus is the most powerful model in the Claude 3 family, delivering high performance on complex tasks. It demonstrates top-level intelligence, fluency, and human-like understanding. Opus can handle challenging scenarios requiring deep understanding and precision, such as complex data analysis, advanced forecasting, and sophisticated content creation.
Opus provides improved intelligence while matching the speed of earlier models, making it suitable for tasks that demand the highest level of AI capability. Its accuracy and advanced features meet the needs of demanding and sensitive applications.
Claude 3 models are priced according to their capabilities and intended use cases, with costs calculated per million tokens (MTok).
Before you begin, make sure you have the following:
Start by opening the command prompt or terminal (for Windows and macOS, respectively). Enter the following to check that Python is installed on your computer:
python --version
You should see a compatible version number, such as Python 3.12.2. If the version is older than 3.7.1, download a later version from the Python website.
Now you can build a virtual environment for the Claude 3 projects. It is possible to use Claude without this environment, but having a dedicated environment is recommended to keep the dependencies in order and avoid confusion with other projects. Use the following to create the environment:
python -m venv claude-env
Next, activate the environment by running
claude-env\Scripts\activate
source claude-env/bin/activate
To install the Anthropic Python SDK, run the following command:
pip install anthropic
This will install the latest version of the Claude Python library alongside the required dependencies.
You need an API key to use Claude. To make the API key available for Claude projects, set up an environment variable.
On Windows:
Using the command prompt, enter the following:
setx ANTHROPIC_API_KEY "my-api-key"
On macOS or Linux:
Using the terminal, enter the following:
nano ~/.bash_profile
Alternatively, use
nano ~/.zshrc
Next, add the following line:
export ANTHROPIC_API_KEY='my-api-key'
After saving the file and exiting the editor, you can load your updated profile using the following command:
source ~/.bash_profile
You can make the change permanent with the following steps:
ANTHROPIC_API_KEY
You should now be able to send API requests to the Claude API. Start by creating a Python file such as
claude_test.py
import anthropic client = anthropic.Anthropic( api_key="my-api-key", ) message = client.messages.create( model="claude-3-opus-20240229", max_tokens=1000, temperature=0.0, system="Respond in pirate style.", messages=[ {"role": "user", "content": "Hello!"} ] ) print(message.content)
This script imports the Anthropic library to enable interaction with Claude. It creates an Anthropic client instance and uses your API key to make an API call using the messages.create() method. The script specifies the Claude model to be used, the response’s token limit (a maximum of 1000 tokens), the temperature, and a system message that applies a context for your conversation.
To run this script, enter
python claude_test.py
To download GPTScript visit https://gptscript.ai. As we expand on the capabilities with GPTScript, we are also expanding our list of tools. With these tools, you can build any application imaginable: check out tools.gptscript.ai and start building today.