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
Endpoint | Description | Method | Path |
---|---|---|---|
Chat Completions | Create chat completions from provided messages | POST | /v1/chat/completions |
Completions | Create text completions from a prompt | POST | /v1/completions |
Embeddings | Create embeddings from text | POST | /v1/embeddings |
Models | List available models | GET | /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
Parameter | Type | Required | Description |
---|---|---|---|
model | string | Yes | The model to use for generating the completion (e.g., "gpt-3.5-turbo", "gpt-4") |
messages | array | Yes | An array of message objects representing the conversation history |
temperature | number | No | Sampling temperature (0-2), lower is more deterministic |
max_tokens | integer | No | Maximum number of tokens to generate |
stream | boolean | No | Whether 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
Parameter | Type | Required | Description |
---|---|---|---|
model | string | Yes | The model to use for generating the completion |
prompt | string | Yes | The prompt to generate completions for |
temperature | number | No | Sampling temperature (0-2), lower is more deterministic |
max_tokens | integer | No | Maximum 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:
Model | Description | Context Size |
---|---|---|
gpt-4 | Most advanced GPT-4 model for complex tasks | 8,192 tokens |
gpt-4-32k | GPT-4 with extended context window | 32,768 tokens |
gpt-3.5-turbo | Most capable GPT-3.5 model optimized for chat | 4,096 tokens |
text-embedding-ada-002 | Most capable embedding model for text similarity | 8,191 tokens |
text-davinci-003 | Most capable GPT-3 model for text generation | 4,097 tokens |
claude-2 | Anthropic's Claude 2 model | 100,000 tokens |
claude-instant-1 | Faster, more affordable version of Claude | 100,000 tokens |
Next Steps
Now that you understand the OpenAI-compatible endpoints, you can: