API

Nosia offers experimental compatibility with certain features of the OpenAI API to facilitate integration of existing applications with its platform.

Get an API token

  1. Go as a logged in user to https://nosia.localhost/api_tokens
  2. Generate and copy your token
  3. Use your favorite OpenAI chat completion API client by configuring API base to https://nosia.localhost/v1 and API key with your token.

Start a chat completion

This example demonstrates how to use cURL to send a request to the Nosia API for generating chat completions.

  • Name
    messages
    Type
    array
    Description

    An array of message objects, where each object includes a role (e.g., "user") and content (the user's query).

  • Name
    stream
    Type
    boolean
    Description

    If enabled, partial message updates will be sent incrementally, similar to ChatGPT. Tokens will be delivered as individual server-sent events as soon as they are ready, and the stream will end with a data: [DONE] message.

  • Name
    top_k
    Type
    float
    Description

    Minimizes the likelihood of producing nonsensical output. Increasing this value (e.g., to 100) allows for greater diversity in responses, whereas decreasing it (e.g., to 10) results in more cautious and focused answers. (Default: 40)

  • Name
    top_p
    Type
    float
    Description

    Complements top_k. A higher value (e.g., 0.95) increases text diversity, while a lower value (e.g., 0.5) produces more focused and cautious text. (Default: 0.9)

  • Name
    temperature
    Type
    float
    Description

    Controls the creativity of the model's output. Increasing the temperature leads to more creative responses. (Default: 0.1)

Generate text with cURL

curl "https://nosia.localhost/v1/chat/completions" \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{
   "messages": [
     {
       "role": "user",
       "content": "When Ruby 3.3.7 will be released?"
     }
   ],
   "model": "nosia",
   "stream": false,
   "top_k": 40.0,
   "top_p": 0.9,
   "temperature": 0.1
 }'

Response

{
  "choices": [
    {
    "finish_reason": "stop",
      "index": 0,
      "message": {
        "content": "Ruby 3.3.7 is expected to be released on January 7th. If any significant changes arise that impact a large number of users, it may be released earlier than scheduled.",
        "role": "assistant"
      }
    }
  ],
  "created": 1732096397,
  "id": "chatcmpl-337797d0-0a32-4029-984e-3a56ba1f163a",
  "model": "nosia-rag",
  "object": "chat.completion",
  "system_fingerprint": "fp_nosia"
}

Was this page helpful?