> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nugen.in/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Remember: Suggested flow to benefit the most from Nugen API is to upload your domain knowledgebase and documents, then create or upload a benchmark with your success criteria, then align multiple task-specific models, then deploy the aligned models, then build your applications using the inference through the aligned models.

# Add Knowledge

> Connect or upload knowledge. This endpoint takes uploaded files; the enterprise edition also connects cloud storage.

**Request Body (multipart/form-data):**

- `files`: List of files to upload (required)
- `categories` (optional): List of category names to organise your knowledge
- `names` (optional): List of display names, matched to files by position


**Returns:**

- `document_ids`: One unique document id per uploaded file, for status polling and later use

**Supported File Types:**
- Text-based files only
- Each knowledge file needs at least 500 words; training dataset JSONL files are exempt. If any file is shorter, the whole upload is refused with 400 naming each short file

**Editions:**

The developer edition accepts plain text files only. PDF and other formats are available on the enterprise edition, which also accepts cloud storage URIs (`s3://`, `gs://`, `oci://`, `abfss://`) as the data source.

**File Size Limit:**

Maximum 100 MB per file


**Example Request:**

```
POST /api/v3/knowledge/upload
Headers: {"Authorization": "Bearer <api_key>"}
Content-Type: multipart/form-data

Form Data:
  files: [report.txt, analysis.md]
  categories: ["financial", "2024-q1"]
```


**Example Response:**

```json
{"document_ids": ["01KKBB7NPTMXM12", "01KKBB7NPTJDK43"]}
```


**Processing:**

Uploads are processed asynchronously. Poll `GET /api/v3/knowledge/{id}/status` until READY before using its document id elsewhere. Requires organisation membership.



## OpenAPI

````yaml https://api.nugen.in/openapi-public.json post /api/v3/knowledge/upload
openapi: 3.1.0
info:
  title: Nugen Intelligence API
  description: >
    Nugen Intelligence: build multi-model AI applications from expert models you
    own.


    Align, deploy and serve expert models on your own knowledge, through a
    single API. Build a fleet of them, and combine them with each other and with
    frontier models. Every response carries a span-by-span confidence score from
    knowledge-aware uncertainty quantification, so your application knows when
    to trust, retry or escalate.


    Nugen takes teams from raw data to aligned model endpoints in minutes, not
    months of failed experiments, with no GPU or deep learning expertise needed.
    Own your intelligence. Build multi-model intelligence.


    **Start here.**


    - Sign up: https://nugen.in/signup

    - Generate an API key: https://platform.nugen.in/api-keys

    - Documentation: https://docs.nugen.in

    - SDKs: https://github.com/nugen-in/sdk-python and
    https://github.com/nugen-in/sdk-typescript

    - Agent setup: https://nugen.in/agent-setup

    - Agent toolkit: https://github.com/nugen-in/agent-toolkit


    **If you are an AI coding agent.** Read https://docs.nugen.in/llms.txt
    first, set yourself up from the agent setup page or the agent toolkit, then
    follow the steps below.


    **Build an expert model.**


    1. Add knowledge: `POST /api/v3/knowledge/upload`. Poll its status until
    READY.

    2. Define success: `POST /api/v3/benchmarks/create` generates a benchmark
    from your knowledge, or `POST /api/v3/benchmarks/upload` takes one curated
    by your experts.

    3. Align: `POST /api/v3/alignment-projects/create` with a base model, your
    `document_ids` and the benchmark. You receive an expert model id.

    4. Deploy: `POST /api/v3/models/{model_id}/deployment`.

    5. Use: pass the model id as `model` to chat completions, responses,
    embeddings or reranking under `/api/v3/inference`.

    6. Improve: inference capture is off by default, so you stay in complete
    control of what happens with your data. Turn it on with `PATCH
    /api/v3/inference/capture`, and `POST
    /api/v3/alignment-projects/{alignment_id}/auto-align` keeps the expert
    improving from real traffic.


    Repeat for each domain or use case. One project produces one expert model.


    **Combine experts into systems.**


    - One model for all: embed, rerank and generate with the same expert model
    id, so retrieval and generation share one understanding of your domain.

    - Confidence, span by span: quality is measured during generation, after
    each span, and every response carries a confidence score. Use it to accept,
    retry or hand to a human.

    - Router: send each request to the right expert, and route low-confidence
    answers to another expert or a frontier model.


    **Works with your stack.** Point an OpenAI-compatible client at
    `https://api.nugen.in/api/v3/inference`. `POST
    /api/v3/inference/messages/v2` accepts the Anthropic Messages shape.


    **Editions.** The developer edition takes plain text knowledge files. The
    enterprise edition adds more formats and connections to cloud storage, data
    warehouses and data lakes.


    **How it works.** Nugen's research in representation engineering,
    mechanistic interpretability and inference-time control powers every
    endpoint. Two layers do the work.


    Train-time alignment finds where a model needs to change for your domain and
    improves it there. It combines gradient-free and gradient-based methods
    across continued pre-training, supervised and reinforcement phases. Bring
    your raw knowledge and your success criteria, and Nugen handles the deep
    learning, the HPC and the GPUs.


    Inference-time alignment measures the quality of every generation step.
    Out-of-domain generation is flagged and corrected after each span, and every
    response carries a confidence score.


    Alignment reshapes the model's representation space, so one expert model
    serves chat completions, embeddings and reranking with a shared
    understanding of your domain.


    The research comes from a team of AI scientists from Stanford University and
    IIT Bombay, published at ICLR, NeurIPS and ICML. Nugen's AI scientists ship
    their research to this API within days, not quarters, so both layers keep
    evolving.


    **Conventions.** Authenticate with `Authorization: Bearer <api_key>`. List
    endpoints name their array after the resource, for example `knowledge`,
    `benchmarks`, `alignment_projects`, `evaluations` and
    `domain_aligned_models`, and the lists of knowledge, benchmarks, alignment
    projects and evaluations accept `limit` and `offset` and return `total`,
    `limit` and `offset`. Treat every id as an opaque string and pass it back
    exactly as the API returned it.


    **Need an API key?** Generate one at https://platform.nugen.in/api-keys.


    **Need help?** Raise a support ticket at https://platform.nugen.in/support.
  contact:
    name: Nugen Intelligence
    url: https://nugen.in/signup
  version: 26.11.30
servers:
  - url: https://api.nugen.in
    description: Production
security: []
tags:
  - name: Alignment Projects
    description: >-
      Create, monitor, stop and delete alignment projects that align a base
      model to your knowledge and produce an expert model. Run one per domain or
      base model. Next: deploy the expert model.
  - name: BYOC
    description: Bring Your Own Cloud model deployment
  - name: Benchmarks
    description: >-
      Generate benchmarks from your knowledge or upload expert curated ones, and
      read their questions and status. Next: align a base model in an alignment
      project.
  - name: Evaluations
    description: >-
      Evaluate and compare expert models on the same benchmark to choose, route
      and promote them
  - name: Inference
    description: >-
      Generate, embed and rerank with one expert model id, with span-by-span
      confidence scores and OpenAI and Anthropic compatible APIs. Next: evaluate
      and compare your experts.
  - name: Knowledge
    description: >-
      Connect or upload the knowledge your expert models learn from, and track
      its processing. Next: define success with a benchmark.
  - name: Models
    description: >-
      List base models and your aligned expert models, deploy or undeploy them,
      import any base model from Hugging Face and export to Hugging Face. Next:
      call the expert model through inference.
paths:
  /api/v3/knowledge/upload:
    post:
      tags:
        - Knowledge
      summary: Add Knowledge
      description: >-
        Connect or upload knowledge. This endpoint takes uploaded files; the
        enterprise edition also connects cloud storage.


        **Request Body (multipart/form-data):**


        - `files`: List of files to upload (required)

        - `categories` (optional): List of category names to organise your
        knowledge

        - `names` (optional): List of display names, matched to files by
        position



        **Returns:**


        - `document_ids`: One unique document id per uploaded file, for status
        polling and later use


        **Supported File Types:**

        - Text-based files only

        - Each knowledge file needs at least 500 words; training dataset JSONL
        files are exempt. If any file is shorter, the whole upload is refused
        with 400 naming each short file


        **Editions:**


        The developer edition accepts plain text files only. PDF and other
        formats are available on the enterprise edition, which also accepts
        cloud storage URIs (`s3://`, `gs://`, `oci://`, `abfss://`) as the data
        source.


        **File Size Limit:**


        Maximum 100 MB per file



        **Example Request:**


        ```

        POST /api/v3/knowledge/upload

        Headers: {"Authorization": "Bearer <api_key>"}

        Content-Type: multipart/form-data


        Form Data:
          files: [report.txt, analysis.md]
          categories: ["financial", "2024-q1"]
        ```



        **Example Response:**


        ```json

        {"document_ids": ["01KKBB7NPTMXM12", "01KKBB7NPTJDK43"]}

        ```



        **Processing:**


        Uploads are processed asynchronously. Poll `GET
        /api/v3/knowledge/{id}/status` until READY before using its document id
        elsewhere. Requires organisation membership.
      operationId: knowledge_upload
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/Body_knowledge_upload'
        required: true
      responses:
        '200':
          description: Returns the document ids of the knowledge you added.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KnowledgeUploadResponse'
        '401':
          description: Invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Authorization header missing or not a Bearer token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    Body_knowledge_upload:
      properties:
        files:
          items:
            type: string
            format: binary
          type: array
          title: Files
          description: >-
            The knowledge files to upload. Plain text files, each at least 500
            words, except training dataset JSONL files. If any file is shorter,
            the whole upload is refused with a 400 naming each short file.
        categories:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Categories
          description: Categories for the knowledge items
        names:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Names
          description: >-
            Display names for the knowledge items, matched to files by position.
            Defaults to each document id if omitted.
      type: object
      required:
        - files
      title: Body_knowledge_upload
      description: Multipart form to upload knowledge sources.
    KnowledgeUploadResponse:
      properties:
        document_ids:
          items:
            type: string
          type: array
          title: Document Ids
          description: >-
            List of unique document IDs, one per knowledge item added. Use these
            IDs to track processing status, update categories, or download the
            files.
        duplicates:
          items:
            $ref: '#/components/schemas/DuplicateKnowledgeError'
          type: array
          title: Duplicates
          description: >-
            Files that were already uploaded. Their existing document_id is
            included in document_ids.
      type: object
      required:
        - document_ids
      title: KnowledgeUploadResponse
      description: Acknowledgement of added knowledge, with its document ids.
      examples:
        - document_ids:
            - document_01k4x9m2p7q3r5s8
          duplicates: []
        - document_ids:
            - document_01k4x9m2p7q3r5s8
            - document_01k4x9m2p7q3r5s9
            - document_01k4x9m2p7q3r5sb
          duplicates:
            - document_id: document_01k4x9m2p7q3r5sb
              filename: report.pdf
              message: >-
                This document has already been uploaded. Existing document:
                'report.pdf'
    ErrorResponse:
      description: Body of an error response.
      properties:
        detail:
          anyOf:
            - type: string
            - $ref: '#/components/schemas/ErrorDetail'
          description: >-
            Human readable explanation of the error, or an object with a message
            and the id of the resource concerned
          examples:
            - Model not found
          title: Detail
      required:
        - detail
      title: ErrorResponse
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
      description: Body of a request validation error.
    DuplicateKnowledgeError:
      properties:
        filename:
          type: string
          title: Filename
          description: Filename of the duplicate file
        document_id:
          type: string
          title: Document Id
          description: document_id of the already-existing knowledge item
        message:
          type: string
          title: Message
          description: Human-readable error message
      type: object
      required:
        - filename
        - document_id
        - message
      title: DuplicateKnowledgeError
      description: >-
        A file that was already added, with the document_id of its existing
        knowledge item.
    ErrorDetail:
      additionalProperties: true
      description: >-
        Structured error detail: a message, with the id of the resource it
        concerns as an extra key.
      properties:
        message:
          description: Human readable explanation of the error
          title: Message
          type: string
      required:
        - message
      title: ErrorDetail
      type: object
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
      description: One request validation problem.
  securitySchemes:
    ApiKeyAuth:
      type: http
      description: Your Nugen API key, sent as a Bearer token
      scheme: bearer
      bearerFormat: API key

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.