Back to LiveQuery Integrations

    Claude API

    Claude API from AnthropicAnthropic
    Log in to Manage

    Claude is Anthropic's flagship AI model, capable of engaging in thoughtful dialogue and tackling complex tasks across analysis, writing, math, and coding. Through the Claude API, developers can integrate Claude's capabilities into their applications.

    -- List Models
    SELECT claude.list_models() as resp;
    
    -- Basic completion request
    SELECT claude.post_messages(
      'claude-3-5-sonnet-20241022',
      [{'role': 'user', 'content': 'Hello, how are you?'}],
      1024
      ) as resp;
    
    -- Chat with system message
    SELECT claude.post_messages(
      'claude-3-5-sonnet-20241022',
      [ {'role': 'user', 'content': 'What are the key metrics to track for DEX performance?'}],
      1024,
      1, -- temperature
      1, -- top_p
      1, -- top_k
      'You are a helpful blockchain analytics assistant'
      ) as resp;
    
    -- Chat with batch of messages
    SELECT claude.post_messages_batch(
        {
          'requests': [
            {
              'custom_id': '1',
              'params': {
                'model': 'claude-3-5-sonnet-20241022',
                'max_tokens': 1024,
                'messages': [{'role': 'user', 'content': 'Hello, how are you?'}]
              }
            },
            {
              'custom_id': '2',
              'params': {
                'model': 'claude-3-5-sonnet-20241022',
                'max_tokens': 1024,
                'messages': [{'role': 'user', 'content': 'What time is it?'}]
              }
            }
          ]
        }
      ) as resp;
    
    -- List Message Batches
    SELECT claude.list_message_batches() as resp;
    
    -- List Message before a specific message
    SELECT claude.list_message_batches_with_before(
      'msg_fkjasfdwr', -- the message batch id has a prefix of 'msg_'
      1 -- the number of messages to return
    ) as resp;
    
    -- List Message Batches after a specific message
    SELECT claude.list_message_batches_with_after(
      'msg_fkjasfdwr', -- the message batch id has a prefix of 'msg_'
      1 -- the number of messages to return
    ) as resp;
    
    -- Get Batch Messages, the message batch id has a prefix of 'msg_'
    SELECT claude.get_messages_batch('msg_fkjasfdwr') as resp;
    
    -- Get Message Batch results, the message batch id has a prefix of 'msg_'
    SELECT claude.get_message_batch_results('msg_fkjasfdwr') as resp;
    
    Getting Started

    To get started with the Claude API:

    1. Create an Account
    1. Generate API Key
    • Navigate to the API Keys section
    • Generate a new API key
    • Store your key securely - it won't be shown again
    1. Integration
    • Click the Install button here and enter your API key
    • Go to the LiveQuery section of Data Studio and start querying!
    1. Documentation
    • Review the API documentation for detailed information
    • Explore example queries and best practices
    Overview

    Claude API offers powerful capabilities for a wide range of use cases:

    Natural Language Understanding

    • Sophisticated comprehension of context and nuance
    • Support for multiple languages
    • Ability to understand and follow complex instructions

    Content Generation

    • High-quality writing across various styles and formats
    • Code generation and explanation
    • Document summarization and analysis

    Analysis & Problem Solving

    • Complex reasoning and analysis
    • Mathematical problem solving
    • Step-by-step explanations

    Safety & Ethics

    • Built-in safety measures and ethical principles
    • Transparent about limitations and uncertainties
    • Designed to be helpful while avoiding harmful outputs

    Technical Features

    • Support for both chat and completion endpoints
    • Handles long context windows
    • Fast response times
    • Robust error handling