https://github.com/grottopress/lena
A low-level API client for Anthropic (Claude AI)
https://github.com/grottopress/lena
ai anthropic api claude crystal http-client
Last synced: 6 months ago
JSON representation
A low-level API client for Anthropic (Claude AI)
- Host: GitHub
- URL: https://github.com/grottopress/lena
- Owner: GrottoPress
- License: mit
- Created: 2025-06-23T14:22:46.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2025-06-24T11:39:01.000Z (9 months ago)
- Last Synced: 2025-06-24T12:43:48.361Z (9 months ago)
- Topics: ai, anthropic, api, claude, crystal, http-client
- Language: Crystal
- Homepage:
- Size: 38.1 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Lena
*Lena* is a low-level API client for *Anthropic (Claude AI)*. It features an intuitive interface that maps directly to the *Anthropic* API.
### Usage Examples
```crystal
# Create a new client
client = Lena.new(api_key: "anthropic-api-key")
```
1. Send messages:
```crystal
response = client.messages.create(
model: "claude-3-7-sonnet-20250219",
max_tokens: 1024,
messages: [{role: "user", content: "Hello, world"}]
)
if response.error
response.error.try do |error|
puts error.type
puts error.message
# ...
end
else
puts response.container.try(&.id)
puts response.id
response.content.try &.each do |content|
puts content.data
puts content.text
puts content.type
# ...
end
# ...
end
```
1. List models:
```crystal
response = client.models.list(limit: 10)
if response.error
response.error.try do |error|
puts error.type
puts error.message
# ...
end
else
response.data.try &.each do |model|
puts model.created_at
puts model.display_name
puts model.id
# ...
end
end
```
## Documentation
Find the complete documentation in the `docs/` directory of this repository.
## Development
Generate an API key from your Anthropic [account](https://console.anthropic.com).
Create a `.env.sh` file:
```bash
#!/usr/bin/env bash
#
export ANTHROPIC_API_KEY='your-anthropic-api-key-here'
```
Update the file with your own details. Then run tests with `source .env.sh && crystal spec`.
**IMPORTANT**: Remember to set permissions for your env file to `0600` or stricter: `chmod 0600 .env*`.
## Contributing
1. [Fork it](https://github.com/GrottoPress/lena/fork)
1. Switch to the `master` branch: `git checkout master`
1. Create your feature branch: `git checkout -b my-new-feature`
1. Make your changes, updating changelog and documentation as appropriate.
1. Commit your changes: `git commit`
1. Push to the branch: `git push origin my-new-feature`
1. Submit a new *Pull Request* against the `GrottoPress:master` branch.