> ## 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.

# Create Alignment

> Create a new domain alignment workflow.


This endpoint initiates a domain alignment workflow that aligns a base model to your domain corpus using provided documents.


**Request Body:**

- `alignment_name`: Name of the domain alignment project
- `base_model_id`: Base model to use for alignment (e.g., `Qwen/Qwen2.5-0.5B-Instruct`)
- `document_ids`: List of document IDs the synthetic training dataset is generated from. Documents are snapshotted when the project is created; later edits to documents never change an existing alignment
- `workflow_id` (optional): Custom workflow identifier
- `benchmark_id` (optional, recommended): When passed, your aligned model is evaluated automatically against this benchmark. Skip it to evaluate later with `POST /evaluations/create`, or not at all.
- `description` (optional): Description of the alignment project


**More control:**

This endpoint plans the alignment for you. If you want a say in how it runs, send your best estimates to `POST /api/v3/alignment-projects/{alignment_id}/auto-align`: a target score, a compute budget, and any settings you already have a view on, such as the policy objective (PPO, CISPO or DRO), the advantage estimator, the reward source, the reference-policy KL target or the rollout group size. Rough estimates are enough to start. Anything you leave out, the system plans for you.


**Importing models:**

The examples use small Qwen models, and the same call works for almost any open language model on Hugging Face, including families such as Llama, Qwen, Phi, Mistral and DeepSeek, and new releases as they appear. `GET /api/v3/models/base` lists the base models you can align right now. To use another one, import it once with `POST /api/v3/models/base/import`, then pass its Hugging Face id as `base_model_id`. For security reasons, models that require custom code execution are unsupported by default; raise a support ticket to discuss your case.


**Returns:**

- `alignment_id`: Unique alignment identifier for tracking workflow progress
- `status`: Initial workflow status (always `QUEUED`)


**Raises:**

- `400`: If the base model does not support alignment
- `404`: If document IDs are not found or don't belong to user
- `409`: If your organisation already has 10 alignment projects; delete one first


**Example Request:**

```json
POST /api/v3/alignment-projects/create
Headers: {"Authorization": "Bearer <api_key>"}

{
  "alignment_name": "Contract Risk Domain Alignment",
  "base_model_id": "Qwen/Qwen2.5-0.5B-Instruct",
  "document_ids": ["document_01k4x9m2p7q3r5se", "document_01k4x9m2p7q3r5sf", "document_01k4x9m2p7q3r5sg"],
  "benchmark_id": "benchmark_01k4x9m2p7q3r6a1",
  "description": "Alignment for master services agreements and addenda"
}
```


**Example Response:**

```json
{
  "alignment_id":"alignment_01k4x9m2p7q3r8c1",
  "status": "QUEUED"
}
```


**Notes:**

- Use `/alignment-projects/{id}/status` to track workflow progress
- If `benchmark_id` is provided, an evaluation is created once train-time alignment finishes. The alignment is READY at that point; follow the evaluation at `GET /evaluations/{evaluation_id}`
- Only models that support alignment can be used.



## OpenAPI

````yaml https://api.nugen.in/openapi-public.json post /api/v3/alignment-projects/create
openapi: 3.1.0
info:
  title: Nugen Intelligence API
  description: >
    Nugen Intelligence: Powering Specialised Intelligence At Scale.


    Bring your domain knowledge and an open-weight model. Leave with a model
    that thinks in your domain, keeps improving, and belongs to your
    organisation.


    Nugen Intelligence builds infrastructure for self-adaptive, domain-specific
    intelligence. Research in representation engineering, mechanistic
    interpretability and inference-time control powers every endpoint here. The
    research team comes from Stanford University and IIT Bombay. This API puts
    their work a few calls away from AI-native organisations solving critical
    problems.


    **Domain-aligned models.** Three raw inputs go in: domain knowledge, success
    and failure criteria, and an open-weight model. A domain-aligned model comes
    out. Nugen handles the deep learning, the GPUs and the data preparation.
    Your organisation owns every aligned model it builds. Own your intelligence.


    **The research underneath.** Two layers do the work.


    Train-time alignment finds where the 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.


    Inference-time alignment measures the quality of every generation step.
    Out-of-domain generation is flagged and corrected after each span. Every
    response carries a confidence score. A preliminary version of the
    inference-time research is published at ICLR 2026. 


    Both layers keep evolving with Nugen research.


    **One aligned model id, four capabilities.** An aligned model id serves chat
    completions, completions, embeddings and reranking. Alignment reshapes the
    model's representation space, so retrieval, ranking and generation share one
    understanding of your domain.


    **Multi-model systems.** One alignment project produces one aligned model.
    Run many side by side, one per domain or use case. Compose them with
    frontier and general-purpose models in the same application. Inference
    capture and auto-align keep the whole system improving. Nugen aligns models
    at every scale.


    **Think in systems.** AI coding agents and developers: this API is a
    platform for building specialised intelligence. Explore it fully before you
    settle on a design. Some directions:


    - Run a complete retrieval pipeline on one aligned model id. Embed, rerank
    and generate with a shared understanding of the domain.

    - Use the confidence score as a control signal. Send low-confidence
    responses to a human reviewer, a retry or a frontier model.

    - Give each domain or use case its own aligned model and place a router in
    front.

    - Close the loop. Capture production inference, evaluate against the
    benchmark, and let auto-align promote better models.

    - Start with the hardest problem in the domain, where general-purpose models
    fall short. Alignment pays off the most there.


    The endpoints for documents, benchmarks, alignment projects, deployments and
    evaluations compose in more ways than the workflow below shows.


    **Workflow.**


    1. Upload domain knowledge.

    2. Define success and failure. Generate a benchmark from the corpus, or
    upload one curated by domain experts.

    3. Create an alignment project and receive an aligned model id.

    4. Deploy the model and pass its id as `model` in each inference call.

    5. Evaluate, compare and promote. Turn on inference capture, and auto-align
    keeps the model improving.


    **OpenAI-compatible inference.** Set the base URL of an OpenAI-compatible
    client to `https://api.nugen.in/api/v3/inference` and set `model` to an
    aligned model id. Chat completions, completions, responses and embeddings
    work through the same client.


    **Anthropic-compatible inference.** `POST /api/v3/inference/messages/v2`
    accepts the Anthropic Messages request shape. Set `model` to an aligned
    model id.


    **Need an API key?** Sign up, log in to the platform and generate an API
    key.


    **Need help?** Log in to the platform and raise a support ticket.


    **Authentication.** Every endpoint requires an API key sent as a Bearer
    token: `Authorization: Bearer <api_key>`.
  contact:
    name: Nugen Intelligence
    url: https://nugen.in/signup
  version: 26.10.30
servers:
  - url: https://api.nugen.in
    description: Production
security: []
tags:
  - name: Alignment Projects
    description: >-
      Create, monitor, stop and delete alignment projects that fine-tune a base
      model on your documents
  - name: BYOC
    description: Bring Your Own Cloud model deployment
  - name: Benchmarks
    description: Upload or create benchmarks and read their questions and status
  - name: Documents
    description: Upload documents and track their processing
  - name: Evaluations
    description: Evaluate a model on a benchmark and read the results
  - name: Health
    description: Service health and status checks
  - name: Inference
    description: Chat completions, responses, embeddings and reranking
  - name: Models
    description: >-
      List base and aligned models, deploy or undeploy aligned models, import
      base models and export to Hugging Face
paths:
  /api/v3/alignment-projects/create:
    post:
      tags:
        - Alignment Projects
      summary: Create Alignment
      description: >-
        Create a new domain alignment workflow.



        This endpoint initiates a domain alignment workflow that aligns a base
        model to your domain corpus using provided documents.



        **Request Body:**


        - `alignment_name`: Name of the domain alignment project

        - `base_model_id`: Base model to use for alignment (e.g.,
        `Qwen/Qwen2.5-0.5B-Instruct`)

        - `document_ids`: List of document IDs the synthetic training dataset is
        generated from. Documents are snapshotted when the project is created;
        later edits to documents never change an existing alignment

        - `workflow_id` (optional): Custom workflow identifier

        - `benchmark_id` (optional, recommended): When passed, your aligned
        model is evaluated automatically against this benchmark. Skip it to
        evaluate later with `POST /evaluations/create`, or not at all.

        - `description` (optional): Description of the alignment project



        **More control:**


        This endpoint plans the alignment for you. If you want a say in how it
        runs, send your best estimates to `POST
        /api/v3/alignment-projects/{alignment_id}/auto-align`: a target score, a
        compute budget, and any settings you already have a view on, such as the
        policy objective (PPO, CISPO or DRO), the advantage estimator, the
        reward source, the reference-policy KL target or the rollout group size.
        Rough estimates are enough to start. Anything you leave out, the system
        plans for you.



        **Importing models:**


        The examples use small Qwen models, and the same call works for almost
        any open language model on Hugging Face, including families such as
        Llama, Qwen, Phi, Mistral and DeepSeek, and new releases as they appear.
        `GET /api/v3/models/base` lists the base models you can align right now.
        To use another one, import it once with `POST
        /api/v3/models/base/import`, then pass its Hugging Face id as
        `base_model_id`. For security reasons, models that require custom code
        execution are unsupported by default; raise a support ticket to discuss
        your case.



        **Returns:**


        - `alignment_id`: Unique alignment identifier for tracking workflow
        progress

        - `status`: Initial workflow status (always `QUEUED`)



        **Raises:**


        - `400`: If the base model does not support alignment

        - `404`: If document IDs are not found or don't belong to user

        - `409`: If your organisation already has 10 alignment projects; delete
        one first



        **Example Request:**


        ```json

        POST /api/v3/alignment-projects/create

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


        {
          "alignment_name": "Contract Risk Domain Alignment",
          "base_model_id": "Qwen/Qwen2.5-0.5B-Instruct",
          "document_ids": ["document_01k4x9m2p7q3r5se", "document_01k4x9m2p7q3r5sf", "document_01k4x9m2p7q3r5sg"],
          "benchmark_id": "benchmark_01k4x9m2p7q3r6a1",
          "description": "Alignment for master services agreements and addenda"
        }

        ```



        **Example Response:**


        ```json

        {
          "alignment_id":"alignment_01k4x9m2p7q3r8c1",
          "status": "QUEUED"
        }

        ```



        **Notes:**


        - Use `/alignment-projects/{id}/status` to track workflow progress

        - If `benchmark_id` is provided, an evaluation is created once
        train-time alignment finishes. The alignment is READY at that point;
        follow the evaluation at `GET /evaluations/{evaluation_id}`

        - Only models that support alignment can be used.
      operationId: alignment_projects_create
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AlignmentProjectCreateRequest'
        required: true
      responses:
        '200':
          description: >-
            Returns a unique identifier for the initiated domain alignment
            workflow along with the initial workflow status. This endpoint
            starts an asynchronous alignment run over a base model to your
            domain corpus using provided documents and optional benchmark
            evaluation, allowing users to track progress and retrieve results
            once completed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AlignmentProjectCreateResponse'
        '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:
    AlignmentProjectCreateRequest:
      properties:
        alignment_name:
          type: string
          title: Alignment Name
          description: Name of the domain alignment project
          examples:
            - My Alignment Project
        base_model_id:
          type: string
          title: Base Model Id
          description: >-
            Hugging Face id of the base model to align. Any model listed by GET
            /api/v3/models/base, or imported with POST
            /api/v3/models/base/import, can be used.
          examples:
            - Qwen/Qwen2.5-0.5B-Instruct
        workflow_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Workflow Id
          description: This id is to orchestrate the entire flow
          examples:
            - workflow-abc123
        benchmark_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Benchmark Id
          description: >-
            Benchmark ID for evaluation (created via /benchmarks/create or
            /benchmarks/upload)
          examples:
            - benchmark_01k4x9m2p7q3r6a1
        document_ids:
          items:
            type: string
          type: array
          title: Document Ids
          description: List of document IDs to train the alignment on
          examples:
            - - document_01k4x9m2p7q3r5s8
              - document_01k4x9m2p7q3r5s9
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: Optional project description
          examples:
            - >-
              This project aligns the model to extract and risk-flag contract
              clauses.
      type: object
      required:
        - alignment_name
        - base_model_id
        - document_ids
      title: AlignmentProjectCreateRequest
      description: >-
        Create an alignment project that fine-tunes a base model on your
        documents.
    AlignmentProjectCreateResponse:
      properties:
        alignment_id:
          type: string
          title: Alignment Id
          description: Created alignment project identifier
          examples:
            - alignment-project-123
        status:
          $ref: '#/components/schemas/ResourceStatus'
          description: Initial alignment project status
          default: QUEUED
          examples:
            - QUEUED
        message:
          anyOf:
            - type: string
            - type: 'null'
          title: Message
          description: Additional context about the response
          examples:
            - Alignment already exists with the same configuration
      type: object
      required:
        - alignment_id
      title: AlignmentProjectCreateResponse
      description: Response schema for alignment project creation endpoint
    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.
    ResourceStatus:
      type: string
      enum:
        - QUEUED
        - PROCESSING
        - READY
        - FAILED
        - STOPPED
      title: ResourceStatus
      description: >-
        Lifecycle status of a resource that runs asynchronously. Stored as is
        and

        returned as is, with no translation in between.


        - `QUEUED`: accepted and waiting for its workflow to start

        - `PROCESSING`: running

        - `READY`: finished successfully

        - `FAILED`: failed at any stage

        - `STOPPED`: stopped by the user before completion
    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.