> This page is also available as Markdown: append .md to its URL. The full index of Sikaru docs is at https://docs.sikaru.ai/llms.txt. Code examples use only operations from the public API reference at https://docs.sikaru.ai/api-reference.

# Completions

POST https://api.sikaru.ai/v1/completions
Content-Type: application/json

Reference: https://docs.sikaru.ai/api-reference/completions/create

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Body (application/json)

This endpoint expects an object.

- `model` (string, required)
- `prompt` (V1CompletionsPostRequestBodyContentApplicationJsonSchemaPrompt, required)
- `stream` (true, required)
- `best_of` (integer, optional, nullable)
- `echo` (boolean, optional, nullable)
- `frequency_penalty` (double, optional, nullable)
- `logit_bias` (map from string to any, optional, nullable)
- `logprobs` (integer, optional, nullable)
- `max_tokens` (integer, optional, nullable)
- `min_p` (double, optional, nullable)
- `models` (list of string, optional, nullable)
- `n` (integer, optional, nullable)
- `presence_penalty` (double, optional, nullable)
- `provider` (map from string to any, optional, nullable)
- `repetition_penalty` (double, optional, nullable)
- `route` (string, optional, nullable)
- `seed` (integer, optional, nullable)
- `stop` (V1CompletionsPostRequestBodyContentApplicationJsonSchemaStop, optional, nullable)
- `stream_options` (map from string to any, optional, nullable)
- `suffix` (string, optional, nullable)
- `temperature` (double, optional, nullable)
- `top_k` (integer, optional, nullable)
- `top_p` (double, optional, nullable)
- `transforms` (list of string, optional, nullable)
- `typical_p` (double, optional, nullable)
- `usage` (map from string to any, optional, nullable)
- `user` (string, optional, nullable)

## Response

### 200

- Streaming response of `Completion`.
- `id` (string, required)
- `object` (string, required)
- `choices` (list of CompletionChoice, optional, nullable)
- `created` (integer, optional, nullable)
- `model` (string, optional, nullable)
- `usage` (CompletionUsage, optional, nullable) — Public CreateChatCompletionResponse fields at this level (CHAT_USAGE_FIELDS); the projection omits the rest.

## Types

### V1CompletionsPostRequestBodyContentApplicationJsonSchemaPrompt

- string
- list of any

### V1CompletionsPostRequestBodyContentApplicationJsonSchemaStop

- string
- list of string

### CompletionChoice

Public CreateCompletionResponse fields at this level (COMPLETION_CHOICE_FIELDS); the projection omits the rest.

- `finish_reason` (string, optional, nullable)
- `index` (integer, optional, nullable)
- `logprobs` (map from string to any, optional, nullable)
- `text` (string, optional, nullable)

### CompletionUsage

Public CreateChatCompletionResponse fields at this level (CHAT_USAGE_FIELDS); the projection omits the rest.

- `completion_tokens` (integer, optional, nullable)
- `completion_tokens_details` (map from string to any, optional, nullable)
- `prompt_tokens` (integer, optional, nullable)
- `prompt_tokens_details` (map from string to any, optional, nullable)
- `total_tokens` (integer, optional, nullable)

## Examples

**Request**

```json
{
  "model": "string",
  "prompt": "string",
  "stream": true
}
```

**SDK Code**

```python
import requests

url = "https://api.sikaru.ai/v1/completions"

payload = {
    "model": "string",
    "prompt": "string",
    "stream": True
}
headers = {
    "Authorization": "Bearer <apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.sikaru.ai/v1/completions';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <apiKey>', 'Content-Type': 'application/json'},
  body: '{"model":"string","prompt":"string","stream":true}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.sikaru.ai/v1/completions"

	payload := strings.NewReader("{\n  \"model\": \"string\",\n  \"prompt\": \"string\",\n  \"stream\": true\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.sikaru.ai/v1/completions")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"string\",\n  \"prompt\": \"string\",\n  \"stream\": true\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.sikaru.ai/v1/completions")
  .header("Authorization", "Bearer <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"string\",\n  \"prompt\": \"string\",\n  \"stream\": true\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.sikaru.ai/v1/completions', [
  'body' => '{
  "model": "string",
  "prompt": "string",
  "stream": true
}',
  'headers' => [
    'Authorization' => 'Bearer <apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.sikaru.ai/v1/completions");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"string\",\n  \"prompt\": \"string\",\n  \"stream\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "string",
  "prompt": "string",
  "stream": true
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sikaru.ai/v1/completions")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```