Pomelo

OpenAI Compatible Endpoints

Our API provides a set of endpoints that are fully compatible with OpenAI's API specification, allowing you to easily migrate existing OpenAI integrations to our platform. These endpoints support text completions, chat completions, embeddings, and more.

Drop-in Replacement

Our OpenAI-compatible endpoints can be used as a direct replacement for OpenAI's API. Simply change the base URL in your existing code to point to our API, and everything will continue to function as expected with the same request and response formats.

Available Endpoints

EndpointDescriptionMethodPath
Chat CompletionsCreate chat completions from provided messagesPOST/v1/chat/completions
CompletionsCreate text completions from a promptPOST/v1/completions
EmbeddingsCreate embeddings from textPOST/v1/embeddings
ModelsList available modelsGET/v1/models

Chat Completions

The chat completions endpoint is designed for conversational AI interactions. It accepts a list of messages and returns a model-generated message as a response.

Request

POST https://api.pomeloapi.example.com/v1/chat/completions

{
  "model": "gpt-3.5-turbo",
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Hello, who are you?"}
  ],
  "temperature": 0.7,
  "max_tokens": 150
}

Parameters

ParameterTypeRequiredDescription
modelstringYesThe model to use for generating the completion (e.g., "gpt-3.5-turbo", "gpt-4")
messagesarrayYesAn array of message objects representing the conversation history
temperaturenumberNoSampling temperature (0-2), lower is more deterministic
max_tokensintegerNoMaximum number of tokens to generate
streambooleanNoWhether to stream the response as it's being generated

Response

{
  "id": "chatcmpl-123456789",
  "object": "chat.completion",
  "created": 1677858242,
  "model": "gpt-3.5-turbo",
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "I am an AI assistant created to help answer questions and provide information. How can I assist you today?"
      },
      "finish_reason": "stop",
      "index": 0
    }
  ],
  "usage": {
    "prompt_tokens": 19,
    "completion_tokens": 29,
    "total_tokens": 48
  }
}

Example: Python

import ai_console

# Initialize the client with your API key
client = ai_console.Client(api_key="your_api_key")

# Create a chat completion
response = client.chat.completions.create(
    model="gpt-3.5-turbo",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Tell me about quantum computing in simple terms."}
    ],
    temperature=0.7,
    max_tokens=300
)

# Print the response
print(response.choices[0].message.content)

Example: JavaScript

import { AIConsole } from 'pomeloapi';

// Initialize the client with your API key
const client = new AIConsole({ apiKey: 'your_api_key' });

async function main() {
  // Create a chat completion
  const response = await client.chat.completions.create({
    model: 'gpt-3.5-turbo',
    messages: [
      { role: 'system', content: 'You are a helpful assistant.' },
      { role: 'user', content: 'Tell me about quantum computing in simple terms.' }
    ],
    temperature: 0.7,
    max_tokens: 300
  });

  // Print the response
  console.log(response.choices[0].message.content);
}

main().catch(console.error);

Completions

Note: The completions endpoint is being deprecated in favor of the chat completions endpoint. We recommend using chat completions for all new applications.

The completions endpoint generates text completions from a provided prompt. It is useful for tasks like text generation, summarization, and more.

Request

POST https://api.pomeloapi.example.com/v1/completions

{
  "model": "text-davinci-003",
  "prompt": "Write a poem about artificial intelligence",
  "temperature": 0.7,
  "max_tokens": 150
}

Parameters

ParameterTypeRequiredDescription
modelstringYesThe model to use for generating the completion
promptstringYesThe prompt to generate completions for
temperaturenumberNoSampling temperature (0-2), lower is more deterministic
max_tokensintegerNoMaximum number of tokens to generate

Embeddings

The embeddings endpoint generates vector representations of text that can be used for semantic search, text classification, clustering, and other natural language processing tasks.

Request

POST https://api.pomeloapi.example.com/v1/embeddings

{
  "model": "text-embedding-ada-002",
  "input": "The quick brown fox jumps over the lazy dog"
}

Models

The models endpoint provides a list of all available models on the platform.

Request

GET https://api.pomeloapi.example.com/v1/models

Supported Models

Our platform supports a wide range of OpenAI-compatible models. Here are some of the models you can use with our API:

ModelDescriptionContext Size
gpt-4Most advanced GPT-4 model for complex tasks8,192 tokens
gpt-4-32kGPT-4 with extended context window32,768 tokens
gpt-3.5-turboMost capable GPT-3.5 model optimized for chat4,096 tokens
text-embedding-ada-002Most capable embedding model for text similarity8,191 tokens
text-davinci-003Most capable GPT-3 model for text generation4,097 tokens
claude-2Anthropic's Claude 2 model100,000 tokens
claude-instant-1Faster, more affordable version of Claude100,000 tokens

Next Steps

Now that you understand the OpenAI-compatible endpoints, you can: