lena

A low-level API client for Anthropic (Claude AI)

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

# Create a new client
client = Lena.new(api_key: "anthropic-api-key")
  1. Send messages:

    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
    
  2. List models:

    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.

Create a .env.sh file:

#!/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
  2. Switch to the master branch: git checkout master
  3. Create your feature branch: git checkout -b my-new-feature
  4. Make your changes, updating changelog and documentation as appropriate.
  5. Commit your changes: git commit
  6. Push to the branch: git push origin my-new-feature
  7. Submit a new Pull Request against the GrottoPress:master branch.
Repository

lena

Owner
Statistic
  • 0
  • 0
  • 0
  • 0
  • 2
  • about 15 hours ago
  • June 23, 2025
License

MIT License

Links
Synced at

Tue, 24 Jun 2025 13:20:13 GMT

Languages