What is an OpenAI-compatible API?

Many LLM providers and self-hosted inference servers - OpenAI itself, Azure OpenAI, Groq, OpenRouter, Together AI, Mistral, DeepSeek, vLLM, llama.cpp's server, LM Studio, and Ollama's OpenAI-compatible mode - all expose the same REST interface popularized by OpenAI: JSON requests to endpoints like /v1/chat/completions, authenticated with a Bearer token in the Authorization header. This lets you swap providers without rewriting your integration code.

Hand-writing a correct cURL command for these endpoints means getting the URL, headers, and JSON body exactly right, especially when tuning sampling parameters like temperature and penalties or switching between chat, legacy completions, and embeddings requests.

Tool description

This tool generates ready-to-use cURL commands for any OpenAI-compatible API. Set the base URL, endpoint, model, and parameters, and get a properly formatted cURL command instantly, ready to paste into your terminal or scripts.

Examples

Chat completion:

curl -X POST "https://api.openai.com/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
  "model": "gpt-4o-mini",
  "messages": [
    { "role": "system", "content": "You are a helpful coding assistant." },
    { "role": "user", "content": "Write a Python function to reverse a string" }
  ],
  "temperature": 0.3,
  "stream": false
}'

Self-hosted server (vLLM, llama.cpp, LM Studio, ...):

curl -X POST "http://localhost:8000/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
  "model": "llama-3-8b-instruct",
  "messages": [
    { "role": "user", "content": "Summarize the plot of Hamlet in two sentences" }
  ],
  "stream": true
}'

Embeddings:

curl -X POST "https://api.openai.com/v1/embeddings" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
  "model": "text-embedding-3-small",
  "input": "The quick brown fox jumps over the lazy dog"
}'

Features

  • Supports the three most common OpenAI-compatible endpoints: /chat/completions, /completions, and /embeddings
  • Works with any compatible base URL, so it fits OpenAI, Azure, Groq, OpenRouter, Together AI, and self-hosted servers alike
  • Configurable sampling parameters: temperature, top-p, frequency penalty, presence penalty, max tokens, number of completions, stop sequences, and seed
  • Optional JSON-object response format for chat completions
  • Nothing is sent anywhere - the cURL command is built entirely in your browser, and no API key ever leaves your machine

Options explained

Option Description Default Range
Base URL The API root, without the endpoint path. https://api.openai.com/v1 Any URL
Endpoint Which API endpoint to target. /chat/completions chat, completions, embeddings
Temperature Controls randomness of output. Lower values produce more focused text, higher values increase creativity. 1 0-2
Top P Nucleus sampling threshold. The model considers tokens whose cumulative probability reaches this value. 1 0-1
Frequency penalty Penalizes tokens based on how often they already appeared, reducing verbatim repetition. 0 -2-2
Presence penalty Penalizes tokens that already appeared at all, encouraging the model to introduce new topics. 0 -2-2
Max tokens Maximum number of tokens to generate in the response. Left empty to omit and use the provider's default. - Any integer
Completions (n) How many chat/completion choices to generate for the input. 1 Any integer
Seed Fixed seed for best-effort reproducible output. Leave empty for random results. - Any integer
Stop sequences Comma-separated list of sequences where the API stops generating further tokens. - Any text
Response format Set to JSON object to force the model to return valid JSON output (chat endpoint only). None None / JSON object
Stream When enabled, the response is streamed as server-sent events. Disable to receive the full response at once. Off On / Off