Nenna API: developer documentation
This documentation describes the main API endpoints of Nenna (OpenAI-compatible chat completion interface plus RAG/knowledge functions) and how you integrate them into your own applications.
Before using the API, please follow these best-practice steps:
The API must be enabled on the instance by an admin
Disable unused API paths via the admin
Create an API group with API permissions
Create a new API user and assign it to the API group
Give the API group the matching permissions for models, agents, skills and so on
Log in as the API user and create an API token under User settings -> Account
We recommend not using the API directly through admin accounts.
Productive use of the chat API requires a separate commercial agreement. Write to [email protected] for this. You can find the API for masking at Nenna Shield - API docs.
1. Authentication
All API requests need authentication. Use a Bearer Token (API key from Settings > Account) or a JWT.
Authorization: Bearer YOUR_API_KEY
2. List models
With this endpoint you can retrieve all models available in Nenna.
Endpoint |
|
|---|---|
Description | Lists all models that were created or added in Nenna. |
curl -H "Authorization: Bearer YOUR_API_KEY" \ https://KUNDE.nenna.ai/api/v1/models3. Chat completions
Nenna provides an OpenAI API-compatible chat completion endpoint. With it you can generate chat replies for models inside Nenna (e.g. local models, OpenAI models or Nenna function models).
Endpoint |
|
|---|---|
Content-Type |
|
3.1 Example (cURL)
curl -X POST https://KUNDE.nenna.ai/api/v1/chat/completions \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "OpenAI GPT-4o (EU)", "messages": [ { "role": "user", "content": "Warum ist der Himmel blau?" } ] }'3.2 Example (Python)
import requests
def chat_with_model(token): url = "https://KUNDE.nenna.ai/api/v1/chat/completions" headers = { "Authorization": f"Bearer {token}", "Content-Type": "application/json", } data = { "model": "OpenAI GPT-4o (EU)", "messages": [{"role": "user", "content": "Warum ist der Himmel blau?"}], } resp = requests.post(url, headers=headers, json=data) return resp.json()4. RAG (Retrieval Augmented Generation)
With RAG you can enrich answers with external data (uploaded files / knowledge collections). The typical flow is: upload file → wait for processing → add file to a knowledge collection (optional) → reference in chat completions.
4.1 Upload files
On upload, the file content is extracted and stored in a vector database (embeddings).
Endpoint |
|
|---|---|
Parameters |
|
curl -X POST \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Accept: application/json" \ -F "file=@/path/to/your/file" \ https://KUNDE.nenna.ai/api/v1/files/Important (async & race condition):
File uploads are processed asynchronously by default. The upload returns a file ID right away, and extraction/embedding runs in the background.
If you try to add a file to a knowledge collection too early, a 400 error can occur (e.g. "The content provided is empty…").
4.2 Check processing status
Before adding to knowledge collections, check whether processing is finished.
Endpoint |
|
|---|---|
Optional |
|
Status values
Status | Meaning |
|---|---|
| File is still being processed. |
| Processing finished successfully. |
| Processing failed (details in the |
4.3 Add file to knowledge collection
Once the file is fully processed (completed), you can add it to a knowledge collection (knowledge base).
Endpoint |
|
|---|---|
Body |
|
curl -X POST https://KUNDE.nenna.ai/api/v1/knowledge/{knowledge_id}/file/add \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"file_id": "your-file-id-here"}'4.4 Use files/collections in chat completions
In /api/v1/chat/completions you can reference either a single file or a whole collection, using the field files.
4.4.1 Reference a single file
curl -X POST https://KUNDE.nenna.ai/api/v1/chat/completions \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "OpenAI GPT-4o (EU)", "messages": [ { "role": "user", "content": "Erkläre die Konzepte in diesem Dokument." } ], "files": [ { "type": "file", "id": "your-file-id-here" } ] }'4.4.2 Reference a knowledge collection
curl -X POST https://KUNDE.nenna.ai/api/v1/chat/completions \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "OpenAI GPT-4o (EU)", "messages": [ { "role": "user", "content": "Gib Einblicke aus der Collection." } ], "files": [ { "type": "collection", "id": "your-collection-id-here" } ] }'5. Examples
5.1 Analyzing an image in a custom model
First, create a custom model in Nenna (name here "bildextraktion"), select and configure a suitable model, and add a suitable system prompt for image analysis. After that, the custom model can be called via POST /api/v1/chat/completions (authentication by Bearer Token).
def convert_image_to_base64(image_path_or_url):
"""
Konvertiert eine lokale Bilddatei oder ein Bild von einer URL in einen Base64-kodierten String.
"""
if image_path_or_url.startswith('http://') or image_path_or_url.startswith('https://'):
response = requests.get(image_path_or_url)
response.raise_for_status()
image_bytes = response.content
else:
if not os.path.exists(image_path_or_url):
raise FileNotFoundError(f"Bilddatei nicht gefunden: {image_path_or_url}")
with open(image_path_or_url, "rb") as image_file:
image_bytes = image_file.read()
return base64.b64encode(image_bytes).decode('utf-8')
def chat_with_model(model_name, system_prompt, user_prompt, path_to_image):
"""
Sendet eine Chat-Anfrage mit eingebettetem Base64-Bild an die Nenna API.
"""
api_url = f'{URL}/chat/completions'
headers = {
'Authorization': f'Bearer {TOKEN}',
'Content-Type': 'application/json'
}
image_base64_string = convert_image_to_base64(path_to_image)
data = {
"model": model_name,
"messages": [
{"role": "system", "content": system_prompt},
{
"role": "user",
"content": [
{"type": "text", "text": user_prompt},
{
"type": "image_url",
"image_url": {
"url": "data:image/jpeg;base64," + image_base64_string
}
}
]
}
]
}
response = requests.post(api_url, headers=headers, json=data)
response.raise_for_status()
response_json = response.json()
return response_json['choices'][0]['message']['content']
def main():
if len(sys.argv) < 2:
print("Verwendung: python script_name.py <PFAD_ZUM_BILD>")
sys.exit(1)
image_path = sys.argv[1]
model_to_use = "bildextraktion" # Name des Custom Modells in Nenna
system_instruction = "" # optional: leer lassen, wenn Systemprompt im Custom Modell gepflegt ist
user_question = "Analysiere das Bild"
result = chat_with_model(model_to_use, system_instruction, user_question, image_path)
print(result)
if __name__ == "__main__":
main()FAQ / Troubleshooting
"The content provided is empty…" when adding to the knowledge collection
The cause is usually that the file has not finished processing yet. Fix: check the status and wait until completed comes back.
