Claude Message
Using the API
We provide libraries in Python and Typescript that make it easier to work with the Anthropic API.
Python
Example:
import anthropic
client = anthropic.Anthropic(
api_key="$ROCKAPI_API_KEY",
base_url="https://api.rockapi.ru/anthropic"
)
message = client.messages.create(
model="claude-3-5-sonnet-20240620",
max_tokens=1024,
messages=[
{"role": "user", "content": "Hello, Claude"}
]
)
print(message.content)
Typescript
Typescript library GitHub repo
Example:
import Anthropic from '@anthropic-ai/sdk';
const anthropic = new Anthropic({
apiKey: '$ROCKAPI_API_KEY',
base_url="https://api.rockapi.ru/anthropic"
});
const msg = await anthropic.messages.create({
model: "claude-3-5-sonnet-20240620",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello, Claude" }],
});
console.log(msg);