Reference

API Reference

API Key Hub exposes OpenAI-compatible endpoints. All requests should be sent to the base URL with your API key in the Authorization header.

Base URL: https://xylove.net/v1

Endpoints


POST/v1/chat/completions

Creates a model response for the given chat conversation. This is the primary endpoint for interacting with language models.

Request Body

ParameterTypeDescription
modelrequiredstringID of the model to use (e.g., gpt-4o, claude-sonnet-4-6, gemini-2.5-pro).
messagesrequiredarrayA list of messages comprising the conversation. Each message has a role (system, user, or assistant) and content.
temperaturenumberSampling temperature between 0 and 2. Higher values make output more random. Default: 1.
max_tokensintegerMaximum number of tokens to generate in the response. Default varies by model.
top_pnumberNucleus sampling parameter. An alternative to temperature. Default: 1.
streambooleanIf true, partial message deltas will be sent as server-sent events. Default: false.
stopstring | arrayUp to 4 sequences where the API will stop generating further tokens.
presence_penaltynumberPenalizes new tokens based on whether they appear in the text so far. Range: -2.0 to 2.0.
frequency_penaltynumberPenalizes new tokens based on their existing frequency in the text. Range: -2.0 to 2.0.
toolsarrayA list of tools (functions) the model may call. Each tool is defined with a type, function name, description, and parameters schema.
tool_choicestring | objectControls which tool is called. Options: "none", "auto", or a specific tool object.
response_formatobjectAn object specifying the format of the response. Use {"type": "json_object"} for JSON mode.

Message Object

FieldTypeDescription
rolerequiredstringThe role of the message author: "system", "user", or "assistant".
contentrequiredstringThe content of the message.
namestringAn optional name for the participant.

Example Request

cURL
curl https://xylove.net/v1/chat/completions \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Explain quantum computing in simple terms."}
    ],
    "temperature": 0.7,
    "max_tokens": 512
  }'

Example Response

JSON
{
  "id": "chatcmpl-abc123def456",
  "object": "chat.completion",
  "created": 1712345678,
  "model": "gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Quantum computing uses quantum bits (qubits) that can exist in multiple states simultaneously..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 28,
    "completion_tokens": 156,
    "total_tokens": 184
  }
}

POST/v1/embeddings

Creates an embedding vector representing the input text. Useful for search, clustering, and similarity comparisons.

Request Body

ParameterTypeDescription
modelrequiredstringID of the embedding model (e.g., text-embedding-3-small, text-embedding-3-large).
inputrequiredstring | arrayInput text to embed. Can be a string or array of strings for batch embedding.
encoding_formatstringThe format to return the embeddings in. Either "float" (default) or "base64".
dimensionsintegerThe number of dimensions for the output embeddings (only supported by some models).

Example Request

cURL
curl https://xylove.net/v1/embeddings \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "text-embedding-3-small",
    "input": "API Key Hub makes AI accessible."
  }'

Example Response

JSON
{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [0.0023064255, -0.009327292, 0.0028842222, ...]
    }
  ],
  "model": "text-embedding-3-small",
  "usage": {
    "prompt_tokens": 6,
    "total_tokens": 6
  }
}

GET/v1/models

Lists the currently available models along with their capabilities and pricing information. This endpoint does not require authentication.

Parameters

This endpoint takes no parameters.

Example Request

cURL
curl https://xylove.net/v1/models

Example Response

JSON
{
  "object": "list",
  "data": [
    {
      "id": "gpt-4o",
      "object": "model",
      "owned_by": "openai",
      "capabilities": ["chat", "code", "vision", "function_calling", "json_mode"],
      "context_window": 128000,
      "pricing": {
        "input_per_million": 2.50,
        "output_per_million": 10.00
      }
    },
    {
      "id": "claude-sonnet-4-6",
      "object": "model",
      "owned_by": "anthropic",
      "capabilities": ["chat", "code", "vision", "function_calling"],
      "context_window": 200000,
      "pricing": {
        "input_per_million": 3.00,
        "output_per_million": 15.00
      }
    }
  ]
}

Authentication

All endpoints (except GET /v1/models) require authentication via a Bearer token in the Authorization header:

Authorization: Bearer sk-your-api-key

API keys can be created and managed from your Dashboard. If you send a request without a valid key, you will receive a 401 Unauthorized response.


Rate Limiting

Rate limits are applied per API key. When a rate limit is exceeded, the API returns a 429 status code. Response headers include:

HeaderDescription
x-ratelimit-limit-requestsMaximum requests per minute for your key
x-ratelimit-remaining-requestsRemaining requests in the current window
x-ratelimit-limit-tokensMaximum tokens per minute for your key
x-ratelimit-remaining-tokensRemaining tokens in the current window
retry-afterSeconds to wait before retrying (on 429 responses)

For more details, see the Error Codes page.