Uncensored Completions
Overview
Uncensored completion is an OpenAI compatible API that allows you to create chat conversation and get responses based on the conversation. It is very flexible such that it could answer any question without restriction of answer. You can also use openAI sdk to interact with it. Just like OpenAI, this endpoint uses Bearer
token authentication.
Request
curl -X POST https://modelslab.com/api/uncensored-chat/v1/completions \
-H "Authorization: Bearer $MODELSLAB_API_KEY" \
-H "Content-Type: application/json"
OpenAI SDK
This endpoint offers compatibility with the OpenAI SDKs to support developers and their apps with minimal changes. Once you update the base URL, you can start using the SDKs to make calls to Modelslab with API key.
Attributes
Parameter | Type | Description |
---|---|---|
prompt | Array | prompts to be used for completion. |
max_tokens | Int | The maximum number of tokens (words or characters) allowed in the response. |
Example
Body
Body Raw
{
"prompt": "Write a tagline for an ice cream shop.",
"model": ""
}
Request
- JS
- PHP
- PYTHON
You can import the OpenAI client from openai into your javascript application and change the base URL and API key.
import OpenAI from "openai";
const openai = new OpenAI({
apiKey: "<api key>",
baseURL: "https://modelslab.com/api/uncensored-chat/v1",
});
const completion = await openai.chat.completions.create({
model: "ModelsLab/Llama-3.1-8b-Uncensored-Dare",
prompt: "Write a tagline for an ice cream shop.",
});
console.log(completion.choices[0].text);
You can install open source openai php client into your php application and change the base URL and API key.
composer require openai-php/client
<?php
$yourApiKey = getenv('YOUR_API_KEY');
$baseUrl = 'https://modelslab.com/api/uncensored-chat/v1';
$client = OpenAI::client($yourApiKey, $baseUrl);
$result = $client->completions()->create([
'model' => 'ModelsLab/Llama-3.1-8b-Uncensored-Dare',
'prompt' => 'Write a tagline for an ice cream shop.'
]);
echo $result->choices[0]->text;
You can import the OpenAI python package into your python application and change the base URL and API key.
pip install openai
import os
from openai import OpenAI
MODELSLAB_API_KEY = os.getenv("MODELSLAB_API_KEY")
client = OpenAI(
api_key=MODELSLAB_API_KEY,
base_url="https://modelslab.com/api/uncensored-chat/v1",
)
response = client.completions.create(
model="ModelsLab/Llama-3.1-8b-Uncensored-Dare",
prompt="Write a tagline for an ice cream shop."
)
print(response.choices[0].text)
Response
{
"object": "text_completion",
"created": 1732624363,
"model": "ModelsLab/Llama-3.1-8b-Uncensored-Dare",
"choices": [
{
"text": "\"Indulge in our destructive addiction of ice cream.\"",
"index": 0,
"logprobs": null,
"finish_reason": "length",
"stop_reason": null,
"prompt_logprobs": null
}
],
"usage": {
"prompt_tokens": 122,
"completion_tokens": 13,
"total_tokens": 135
}
}