### Python Quickstart: Chat Completions Source: https://kolank.com/docs/index Demonstrates how to use the Kolank Python client to make chat completion requests. It includes setting the base URL, API key, and model, then sending a user message to get a response. ```python from openai import OpenAI client = OpenAI( base_url="https://kolank.com/api/v1", api_key="" # get one from https://kolank.com/keys, ) completion = client.chat.completions.create( model="openai/gpt-4o", messages=[ { "role": "user", "content": "What is the capital of France?", } ], ) print(completion.choices[0].message.content) ``` -------------------------------- ### JavaScript Quickstart: Chat Completions Source: https://kolank.com/docs/index Illustrates how to integrate Kolank using the JavaScript client for chat completion requests. It covers initializing the client with Kolank's base URL and API key, and making a request to the chat completions endpoint. ```javascript import OpenAI from 'openai'; const openai = new OpenAI({ baseURL: 'https://kolank.com/api/v1', apiKey: '', //get one from https://kolank.com keys, }); async function main() { const completion = await openai.chat.completions.create({ model: 'openai/gpt-4o', messages: [{ role: 'user', content: 'What is the capital of France?' }], }); console.log(completion.choices[0].message); } main(); ``` -------------------------------- ### cURL Quickstart: Chat Completions Source: https://kolank.com/docs/index Shows how to make a chat completion request to the Kolank API using cURL. This includes setting the endpoint URL, content type, authorization header with the API key, and the JSON payload for the model and messages. ```curl curl https://kolank.com/api/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $KOLANK_API_KEY" \ -d '{ "model": "openai/gpt-4o", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' ``` -------------------------------- ### Kolank API: Chat Completions Endpoint Source: https://kolank.com/docs/index Details the primary endpoint for generating chat-based model responses. This documentation covers the HTTP method, URL, request body structure, and the expected JSON response format, including usage statistics. ```APIDOC POST https://kolank.com/api/v1/chat/completions Creates a model response for the given chat conversation. Request Body: model: string (required) - The name of the Kolank model to use (e.g., "openai/gpt-4o"). messages: array of objects (required) - A list of message objects, each with a 'role' (user, assistant, system) and 'content' (string). temperature: number (optional) - Controls randomness. Lower values make output more focused and deterministic. max_tokens: integer (optional) - The maximum number of tokens to generate in the completion. Response Body: id: string - Unique identifier for the completion. object: string - Type of object returned (e.g., "chat.completion"). created: integer - Unix timestamp of when the completion was created. model: string - The model used for the completion. choices: array of objects - A list of completion choices. index: integer - The index of the choice. message: object - The message object from the assistant. role: string - Role of the message sender (e.g., "assistant"). content: string - The generated content of the message. logprobs: null - Placeholder for log probabilities. finish_reason: string - The reason the model stopped generating tokens (e.g., "stop"). usage: object - Token usage statistics. prompt_tokens: integer - Number of tokens in the prompt. completion_tokens: integer - Number of tokens in the completion. total_tokens: integer - Total tokens used in the request. system_fingerprint: string - A fingerprint for the system used. Example Response: { "id": "chatcmpl-9juedQHAO0LLaqqr1yRDYWg0afZhx", "object": "chat.completion", "created": 1720729567, "model": "gpt-4o-2024-05-13", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Sure! Let's break down quantum computing into simpler terms ..." }, "logprobs": null, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 13, "completion_tokens": 392, "total_tokens": 405 }, "system_fingerprint": "fp_d33f7b429e" } ``` -------------------------------- ### KOLANK API Request Body Parameters Source: https://kolank.com/docs/index Defines the parameters accepted in the request body for KOLANK API calls, including message structure, model selection, and various configuration options for controlling generation behavior, streaming, and tool usage. API key authentication is required. ```APIDOC KOLANK API Request Body: Parameters: messages (array, Required): List of messages in the conversation. model (string, Required): ID of the model to use. See the model endpoint compatibility table for details on supported models. frequency_penalty (number or null, Optional): Penalizes repeated tokens. Range: -2.0 to 2.0. logit_bias (map, Optional): Adjusts token likelihood with JSON object. Range: -100 to 100. logprobs (boolean or null, Optional): Returns log probabilities of output tokens if true. top_logprobs (integer or null, Optional): Returns top token probabilities. Range: 0 to 20. max_tokens (integer or null, Optional): Maximum tokens in chat completion. Limited by model context length. n (integer or null, Optional): Number of completion choices per message. Defaults to 1 to minimize costs. presence_penalty (number or null, Optional): Encourages diverse topic exploration. Range: -2.0 to 2.0. response_format (object, Optional): Specifies output format for the model. Supports JSON mode. seed (integer or null, Optional): Beta feature. Optional seed for deterministic sampling. service_tier (string or null, Optional): Specifies the latency tier for request processing. Relevant for scale tier service. stop (string / array / null, Optional): Up to 4 sequences where the API stops generating tokens. stream (boolean or null, Optional): Enables partial message deltas in streaming mode. stream_options (object or null, Optional): Options for streaming response. temperature (number or null, Optional): Controls output randomness. Range: 0 to 2. Defaults to 1. top_p (number or null, Optional): Uses nucleus sampling to control token diversity. Range: 0 to 1. Defaults to 1. tools (array, Optional): List of tools (functions) the model may call. Up to 128 functions supported. tool_choice (string or object, Optional): Controls model behavior regarding tool usage. Defaults to "none". parallel_tool_calls (boolean, Optional): Whether to enable parallel function calling during tool use. Defaults to true. user (string, Optional): Unique identifier for end-user monitoring and abuse detection. Authentication: Replace KOLANK_API_KEY with your personal KOLANK API key. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.