Skip to main content

Troubleshooting

Find solutions to common issues when working with Meibel AI.

Authentication Issues

Invalid API Key Error

Problem: Getting “401 Unauthorized” or “Invalid API key” errors. Solutions:
  1. Verify your API key is correct:
    print(os.getenv("MEIBELAI_API_KEY_HEADER"))
    
  2. Check the key hasn’t expired in the Console
  3. Ensure you’re using the correct header format:
    client = Meibelai(api_key_header="your-key-here")
    

Permission Denied

Problem: “403 Forbidden” errors when accessing resources. Solutions:
  • Verify your API key has the necessary permissions
  • Check if you’re accessing resources in the correct organization
  • Ensure you’re not exceeding plan limits

Connection Issues

Timeout Errors

Problem: Requests timing out before completion. Solutions:
# Increase timeout
client = Meibelai(
    api_key_header=os.getenv("MEIBELAI_API_KEY_HEADER"),
    timeout=60  # 60 seconds
)

# For specific operations
response = client.rag.chat(
    messages=[{"role": "user", "content": "Query"}],
    execution_control={"timeout": 45}
)

SSL Certificate Errors

Problem: SSL verification failures. Solutions:
  1. Update your certificates:
    pip install --upgrade certifi
    
  2. For development only (not recommended for production):
    client = Meibelai(
        api_key_header="your-key",
        verify_ssl=False  # Only for debugging
    )
    

Rate Limiting

429 Too Many Requests

Problem: Hitting rate limits. Solutions:
  1. Implement exponential backoff:
    import time
    from meibelai.core import MeibelaiError
    
    def retry_with_backoff(func, max_retries=3):
        for i in range(max_retries):
            try:
                return func()
            except MeibelaiError as e:
                if e.status_code == 429 and i < max_retries - 1:
                    wait_time = 2 ** i
                    time.sleep(wait_time)
                else:
                    raise
    
  2. Use batch operations when possible
  3. Consider upgrading your plan for higher limits

Data Issues

Empty Response

Problem: Getting empty or null responses. Solutions:
  1. Check if datasource has content:
    elements = client.dataelements.list(datasource_id=your_id)
    print(f"Elements in datasource: {len(elements)}")
    
  2. Verify confidence threshold isn’t too high:
    response = client.rag.chat(
        messages=[{"role": "user", "content": "Query"}],
        datasource_ids=[datasource_id],
        confidence_threshold=0.5  # Lower threshold
    )
    

Incorrect Results

Problem: AI returning inaccurate or irrelevant responses. Solutions:
  1. Improve your prompts:
    messages = [
        {"role": "system", "content": "You are a helpful assistant. Be precise and accurate."},
        {"role": "user", "content": "Specific question here"}
    ]
    
  2. Add more context to your data:
    client.dataelements.create(
        datasource_id=datasource_id,
        name="Document",
        content="Your content",
        metadata={
            "category": "technical",
            "date": "2024-01",
            "relevance": "high"
        }
    )
    

Performance Issues

Slow Response Times

Problem: API calls taking longer than expected. Solutions:
  1. Use streaming for long responses:
    stream = client.rag.chat_stream(
        messages=[{"role": "user", "content": "Query"}],
        datasource_ids=[datasource_id]
    )
    
    for chunk in stream:
        print(chunk.choices[0].delta.content, end="")
    
  2. Optimize your queries:
    • Use specific datasources instead of searching all
    • Set appropriate token limits
    • Enable caching when possible

Memory Issues

Problem: Running out of memory with large datasets. Solutions:
  1. Process data in batches:
    def process_in_batches(items, batch_size=10):
        for i in range(0, len(items), batch_size):
            batch = items[i:i + batch_size]
            yield process_batch(batch)
    
  2. Use async operations for better resource usage

SDK-Specific Issues

Import Errors

Problem: Can’t import the Meibel AI SDK. Solutions:
# Reinstall the SDK
pip uninstall meibelai
pip install git+https://github.com/meibel-ai/meibelai-python.git

# Check installation
python -c "import meibelai; print(meibelai.__version__)"

Version Conflicts

Problem: Dependency conflicts with other packages. Solutions:
  1. Use a virtual environment:
    python -m venv meibel_env
    source meibel_env/bin/activate  # On Windows: meibel_env\Scripts\activate
    pip install git+https://github.com/meibel-ai/meibelai-python.git
    
  2. Check Python version compatibility (requires 3.9+)

Debugging Tips

Enable Tracing

Get detailed execution information:
response = client.rag.chat(
    messages=[{"role": "user", "content": "Query"}],
    execution_control={"enable_tracing": True}
)

# Access trace information
if hasattr(response, 'trace'):
    print(response.trace)

Log API Calls

Monitor what’s being sent:
import logging

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger('meibelai')

Getting Help

If you’re still experiencing issues:
  1. Check Status: Visit status.meibel.ai for service status
  2. Documentation: Review the API Reference
  3. Community: Ask questions in our community forum
  4. Support: Contact support@meibel.ai with:
    • Error messages and stack traces
    • Request IDs from error responses
    • Steps to reproduce the issue
    • SDK version and Python version

Next Steps