> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pond3r.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Send a Prompt

> Submit a natural language query for processing

> [!WARNING]
>
> **🚧 Coming Soon**\
> The Messages API is currently being updated to support the new report-focused approach. Check back soon for the latest endpoints.

## Overview

The messages endpoint allows you to submit natural language queries about blockchain data. The API processes messages asynchronously, providing a more robust way to handle longer-running queries.

## Request Flow

1. Submit your query using the `/v1/messages` endpoint
2. Receive a `processingId` to track your request
3. Poll the `/v1/messages/{processingId}/status` endpoint to get the final result

## Examples

### Submitting a Query

**Node.js**

```javascript theme={null}
const axios = require('axios');

async function submitQuery() {
  try {
    const response = await axios.post('https://api.pond3r.xyz/v1/messages', {
      prompt: 'Get the current price of ETH'
    }, {
      headers: {
        'x-api-key': 'YOUR_API_KEY',
        'Content-Type': 'application/json'
      }
    });
    
    return response.data.processingId;
  } catch (error) {
    console.error('Error submitting query:', error.response ? error.response.data : error.message);
    throw error;
  }
}
```

**Python**

```python theme={null}
import requests

def submit_query():
    url = 'https://api.pond3r.xyz/v1/messages'
    headers = {
        'x-api-key': 'YOUR_API_KEY',
        'Content-Type': 'application/json'
    }
    data = {
        'prompt': 'Get the current price of ETH'
    }
    
    try:
        response = requests.post(url, json=data, headers=headers)
        response.raise_for_status()
        return response.json()['processingId']
    except requests.exceptions.RequestException as e:
        print(f"Error submitting query: {e}")
        raise
```

### Checking Status and Getting Results

**Node.js**

```javascript theme={null}
const axios = require('axios');

async function getResult(processingId) {
  try {
    const response = await axios.get(`https://api.pond3r.xyz/v1/messages/${processingId}/status`, {
      headers: {
        'x-api-key': 'YOUR_API_KEY'
      }
    });
    
    return response.data;
  } catch (error) {
    console.error('Error checking status:', error.response ? error.response.data : error.message);
    throw error;
  }
}

// Example of waiting for the result
async function waitForResult(processingId, maxAttempts = 30, interval = 2000) {
  for (let attempt = 0; attempt < maxAttempts; attempt++) {
    const status = await getResult(processingId);
    
    if (status.status === 'FINISHED') {
      return status.result;
    } else if (status.status === 'ERROR') {
      throw new Error(status.errorMessage || 'Processing failed');
    }
    
    // Wait before next attempt
    await new Promise(resolve => setTimeout(resolve, interval));
  }
  
  throw new Error('Timeout waiting for result');
}

// Usage example
async function main() {
  try {
    const processingId = await submitQuery();
    console.log('Processing ID:', processingId);
    
    const result = await waitForResult(processingId);
    console.log('Final result:', result);
  } catch (error) {
    console.error('Error:', error.message);
  }
}
```

**Python**

```python theme={null}
import requests
import time

def get_result(processing_id):
    url = f'https://api.pond3r.xyz/v1/messages/{processing_id}/status'
    headers = {
        'x-api-key': 'YOUR_API_KEY'
    }
    
    try:
        response = requests.get(url, headers=headers)
        response.raise_for_status()
        return response.json()
    except requests.exceptions.RequestException as e:
        print(f"Error checking status: {e}")
        raise

def wait_for_result(processing_id, max_attempts=30, interval=2):
    for attempt in range(max_attempts):
        status = get_result(processing_id)
        
        if status['status'] == 'FINISHED':
            return status['result']
        elif status['status'] == 'ERROR':
            raise Exception(status.get('errorMessage', 'Processing failed'))
        
        # Wait before next attempt
        time.sleep(interval)
    
    raise Exception('Timeout waiting for result')

# Usage example
def main():
    try:
        processing_id = submit_query()
        print('Processing ID:', processing_id)
        
        result = wait_for_result(processing_id)
        print('Final result:', result)
    except Exception as e:
        print('Error:', str(e))
```

## Response Statuses

The status endpoint can return the following statuses:

* `PENDING`: The message has been received and is waiting to be processed
* `PROCESSING`: The message is currently being processed
* `FINISHED`: Processing is complete and the result is available
* `ERROR`: An error occurred during processing

## Error Handling

When an error occurs, the status response will include an `errorMessage` field with details about what went wrong. Common error scenarios include:

* Invalid API key
* Malformed query
* Processing timeout
* Internal server errors

## Best Practices

1. Always implement proper error handling and retry logic
2. Use appropriate polling intervals (2-3 seconds recommended)
3. Set reasonable timeouts for your application
4. Store the `processingId` for later reference if needed
5. Consider implementing a webhook system for production applications


## OpenAPI

````yaml POST /v1/messages
openapi: 3.1.0
info:
  title: Pond3r API
  description: >-
    The Pond3r API allows you to retrieve cryptocurrency price data and other
    blockchain information through natural language queries.
  version: 1.0.0
servers:
  - url: https://api.pond3r.xyz
security:
  - apiKeyAuth: []
paths:
  /v1/messages:
    post:
      description: Submit a natural language query for processing
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - prompt
              properties:
                prompt:
                  type: string
                  description: A natural language query about cryptocurrency prices
                  example: Get the current price of ETH
      responses:
        '201':
          description: Message submitted for processing
          content:
            application/json:
              schema:
                type: object
                required:
                  - processingId
                  - status
                properties:
                  processingId:
                    type: string
                    description: >-
                      Unique identifier for tracking the message processing
                      status
                    example: 123e4567-e89b-12d3-a456-426614174000
                  status:
                    type: string
                    description: Initial status of the request
                    enum:
                      - PENDING
        '400':
          description: Bad request or invalid query
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized - invalid or missing authentication
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Error:
      type: object
      required:
        - error
        - message
      properties:
        error:
          type: integer
          format: int32
        message:
          type: string
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.