MercuryAI
No cap, this is loading fire content
MercuryAI Logo

API Documentation

Integrate MercuryAI into your applications with our simple, powerful API.

Getting Started

Authentication

All API requests require an API key for authentication. You can get your API key from your MercuryAI dashboard.

Authorization: Bearer YOUR_API_KEY

Base URL

All API requests should be made to the following base URL:

https://api.mercuryai.in/v1

Endpoints

POST

/generate

Generate text using any supported AI model.

Request Body

{
  "model": "gpt-4o",
  "prompt": "Write a short poem about AI",
  "max_tokens": 100,
  "temperature": 0.7
}

Response

{
  "id": "gen-123456",
  "text": "Silicon dreams in digital space,\nThoughts electric, learning apace.\nHuman-made minds that grow and see,\nPartners in our shared destiny.",
  "model": "gpt-4o",
  "usage": {
    "prompt_tokens": 7,
    "completion_tokens": 28,
    "total_tokens": 35
  }
}
POST

/chat/completions

Generate a chat completion with any supported AI model.

Request Body

{
  "model": "claude-3-sonnet",
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "What is artificial intelligence?"}
  ],
  "temperature": 0.7
}

Response

{
  "id": "chat-123456",
  "object": "chat.completion",
  "created": 1678048400,
  "model": "claude-3-sonnet",
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "Artificial intelligence (AI) refers to the simulation of human intelligence in machines that are programmed to think and learn like humans. It encompasses various technologies and approaches that enable computers to perform tasks that typically require human intelligence, such as visual perception, speech recognition, decision-making, and language translation."
      },
      "finish_reason": "stop",
      "index": 0
    }
  ],
  "usage": {
    "prompt_tokens": 23,
    "completion_tokens": 64,
    "total_tokens": 87
  }
}

Client Libraries

JavaScript/TypeScript

Install our JavaScript client library:

npm install @mercuryai/client

Example usage:

import { MercuryAI } from '@mercuryai/client';

const mercury = new MercuryAI('YOUR_API_KEY');

async function generateText() {
  const response = await mercury.generate({
    model: 'gpt-4o',
    prompt: 'Write a short poem about AI',
    maxTokens: 100,
    temperature: 0.7
  });
  
  console.log(response.text);
}

generateText();

Python

Install our Python client library:

pip install mercuryai

Example usage:

import mercuryai

client = mercuryai.Client("YOUR_API_KEY")

def generate_text():
    response = client.generate(
        model="gpt-4o",
        prompt="Write a short poem about AI",
        max_tokens=100,
        temperature=0.7
    )
    
    print(response.text)

generate_text()

Ready to get started?

Sign up for MercuryAI and get your API key today.