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/v1Endpoints
- POST /v1/chat/completions -- Create a chat completion
- POST /v1/embeddings -- Create embeddings
- GET /v1/models -- List available models
/v1/chat/completionsCreates a model response for the given chat conversation. This is the primary endpoint for interacting with language models.
Request Body
| Parameter | Type | Description |
|---|---|---|
modelrequired | string | ID of the model to use (e.g., gpt-4o, claude-sonnet-4-6, gemini-2.5-pro). |
messagesrequired | array | A list of messages comprising the conversation. Each message has a role (system, user, or assistant) and content. |
temperature | number | Sampling temperature between 0 and 2. Higher values make output more random. Default: 1. |
max_tokens | integer | Maximum number of tokens to generate in the response. Default varies by model. |
top_p | number | Nucleus sampling parameter. An alternative to temperature. Default: 1. |
stream | boolean | If true, partial message deltas will be sent as server-sent events. Default: false. |
stop | string | array | Up to 4 sequences where the API will stop generating further tokens. |
presence_penalty | number | Penalizes new tokens based on whether they appear in the text so far. Range: -2.0 to 2.0. |
frequency_penalty | number | Penalizes new tokens based on their existing frequency in the text. Range: -2.0 to 2.0. |
tools | array | A list of tools (functions) the model may call. Each tool is defined with a type, function name, description, and parameters schema. |
tool_choice | string | object | Controls which tool is called. Options: "none", "auto", or a specific tool object. |
response_format | object | An object specifying the format of the response. Use {"type": "json_object"} for JSON mode. |
Message Object
| Field | Type | Description |
|---|---|---|
rolerequired | string | The role of the message author: "system", "user", or "assistant". |
contentrequired | string | The content of the message. |
name | string | An optional name for the participant. |
Example Request
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
{
"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
}
}/v1/embeddingsCreates an embedding vector representing the input text. Useful for search, clustering, and similarity comparisons.
Request Body
| Parameter | Type | Description |
|---|---|---|
modelrequired | string | ID of the embedding model (e.g., text-embedding-3-small, text-embedding-3-large). |
inputrequired | string | array | Input text to embed. Can be a string or array of strings for batch embedding. |
encoding_format | string | The format to return the embeddings in. Either "float" (default) or "base64". |
dimensions | integer | The number of dimensions for the output embeddings (only supported by some models). |
Example Request
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
{
"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
}
}/v1/modelsLists 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 https://xylove.net/v1/modelsExample Response
{
"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-keyAPI 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:
| Header | Description |
|---|---|
| x-ratelimit-limit-requests | Maximum requests per minute for your key |
| x-ratelimit-remaining-requests | Remaining requests in the current window |
| x-ratelimit-limit-tokens | Maximum tokens per minute for your key |
| x-ratelimit-remaining-tokens | Remaining tokens in the current window |
| retry-after | Seconds to wait before retrying (on 429 responses) |
For more details, see the Error Codes page.