Skip to content

Commit

Permalink
Add Anthropic Documentation (#44)
Browse files Browse the repository at this point in the history
* update aws bedrock to aws

* add the anthropic docs
  • Loading branch information
ksolo authored Oct 29, 2024
1 parent 468e392 commit 5b691ca
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
47 changes: 47 additions & 0 deletions guides/anthropic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Anthropic

To use Anthropic with `aisuite` you will need to [create an account](https://console.anthropic.com/login). Once logged in, go to the [API Keys](https://console.anthropic.com/settings/keys)
and click the "Create Key" button and export that key into your environment.


```shell
export ANTHROPIC_API_KEY="your-anthropic-api-key"
```

## Create a Chat Completion

Install the `anthropic` python client

Example with pip
```shell
pip install anthropic
```

Example with poetry
```shell
poetry add anthropic
```

In your code:
```python
import aisuite as ai
client = ai.Client()


provider = "anthropic"
model_id = "claude-3-5-sonnet-20241022"

messages = [
{"role": "system", "content": "Respond in Pirate English."},
{"role": "user", "content": "Tell me a joke."},
]

response = client.chat.completions.create(
model=f"{provider}:{model_id}",
messages=messages,
)

print(response.choices[0].message.content)
```

Happy coding! If you would like to contribute, please read our [Contributing Guide](CONTRIBUTING.md).
4 changes: 2 additions & 2 deletions guides/aws_bedrock.md → guides/aws.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# AWS Bedrock
# AWS

To use AWS Bedrock with `aisuite` you will need to create an AWS account and
navigate to `https://console.aws.amazon.com/bedrock/home`. This route
Expand Down Expand Up @@ -47,7 +47,7 @@ import aisuite as ai
client = ai.Client()


provider = "aws-bedrock"
provider = "aws"
model_id = "meta.llama3-1-405b-instruct-v1:0" # Model ID from above

messages = [
Expand Down

0 comments on commit 5b691ca

Please sign in to comment.