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

# Anthropic-compatible Messages

> Accepts the Anthropic Messages request shape and answers in the Anthropic Messages response shape. Set `model` to an aligned model id.

`stream` defaults to false. With `stream` true the endpoint returns the same server-sent chat completion chunks as `POST /api/v3/inference/chat/completions`, not Anthropic stream events.



## OpenAPI

````yaml https://api.nugen.in/openapi-public.json post /api/v3/inference/messages/v2
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, three capabilities.** An aligned model id serves
    chat 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, 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.


    **List responses.** Each list endpoint names its array after the resource,
    for example `documents`, `benchmarks`, `alignment_projects`, `evaluations`
    and `domain_aligned_models`. The lists of documents, benchmarks, alignment
    projects and evaluations accept `limit` and `offset` and return `total`,
    `limit` and `offset`.


    **Resource ids.** Treat every id as an opaque string. Ids issued earlier can
    differ in letter case from newer ones. Pass an id back exactly as the API
    returned it.


    **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.11.16
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: 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/inference/messages/v2:
    post:
      tags:
        - Inference
      summary: Anthropic-compatible Messages
      description: >-
        Accepts the Anthropic Messages request shape and answers in the
        Anthropic Messages response shape. Set `model` to an aligned model id.


        `stream` defaults to false. With `stream` true the endpoint returns the
        same server-sent chat completion chunks as `POST
        /api/v3/inference/chat/completions`, not Anthropic stream events.
      operationId: inference_messages
      parameters:
        - name: X-Session-ID
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Session-Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnthropicRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnthropicResponse'
            text/event-stream:
              schema:
                description: >-
                  Server-sent events. Each data line is one JSON event, and the
                  stream ends with data: [DONE].
                anyOf:
                  - $ref: '#/components/schemas/ChatCompletionChunk'
                  - $ref: '#/components/schemas/ChatCompletionConfidenceEvent'
        '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'
        '504':
          description: >-
            A non-streaming call did not finish before the deadline. Set stream
            to true for long generations.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    AnthropicRequest:
      properties:
        model:
          type: string
          title: Model
          description: Aligned model id, e.g. model_01kmqm4nrn9fw6r
        messages:
          items:
            $ref: '#/components/schemas/AnthropicMessage'
          type: array
          title: Messages
          description: The conversation so far
        max_tokens:
          type: integer
          title: Max Tokens
          description: Maximum tokens to generate
        system:
          anyOf:
            - type: string
            - type: 'null'
          title: System
          description: System prompt
        temperature:
          anyOf:
            - type: number
              maximum: 2
              minimum: 0
            - type: 'null'
          title: Temperature
          description: Sampling temperature, between 0 and 2
          default: 1
        top_p:
          anyOf:
            - type: number
              maximum: 1
              minimum: 0
            - type: 'null'
          title: Top P
          description: Nucleus sampling parameter
        top_k:
          anyOf:
            - type: integer
              minimum: 0
            - type: 'null'
          title: Top K
          description: Sample from the top k tokens only
        stop_sequences:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Stop Sequences
          description: Sequences that end generation
        stream:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Stream
          description: >-
            Stream chat completion chunks as server-sent events. Defaults to
            false.
          default: false
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
          description: Optional metadata, ignored by the model
      type: object
      required:
        - model
        - messages
        - max_tokens
      title: AnthropicRequest
      description: A request in the Anthropic Messages shape.
    AnthropicResponse:
      properties:
        id:
          type: string
          title: Id
          description: Unique identifier of the message
        type:
          type: string
          const: message
          title: Type
          description: Always "message".
        role:
          type: string
          const: assistant
          title: Role
          description: Always "assistant".
        content:
          items:
            $ref: '#/components/schemas/AnthropicContentBlock'
          type: array
          title: Content
          description: Generated content blocks
        model:
          type: string
          title: Model
          description: Model id the caller sent
        stop_reason:
          anyOf:
            - type: string
            - type: 'null'
          title: Stop Reason
          description: Why generation ended
        stop_sequence:
          anyOf:
            - type: string
            - type: 'null'
          title: Stop Sequence
          description: The stop sequence that ended generation, if any
        usage:
          $ref: '#/components/schemas/AnthropicUsage'
          description: Token counts for the call
      type: object
      required:
        - id
        - type
        - role
        - content
        - model
        - usage
      title: AnthropicResponse
      description: A reply in the Anthropic Messages shape.
    ChatCompletionChunk:
      additionalProperties: true
      description: >-
        Represents a streamed chunk of a chat completion response returned

        by the model, based on the provided input.

        [Learn
        more](https://platform.openai.com/docs/guides/streaming-responses).


        The final chunk before data: [DONE] has empty choices and carries the
        usage.
      properties:
        id:
          title: Id
          type: string
        choices:
          items:
            $ref: '#/components/schemas/Choice'
          title: Choices
          type: array
        created:
          title: Created
          type: integer
        model:
          title: Model
          type: string
        object:
          const: chat.completion.chunk
          title: Object
          type: string
        service_tier:
          anyOf:
            - enum:
                - auto
                - default
                - flex
                - scale
                - priority
              type: string
            - type: 'null'
          default: null
          title: Service Tier
        system_fingerprint:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: System Fingerprint
        usage:
          anyOf:
            - $ref: '#/components/schemas/CompletionUsage'
            - type: 'null'
          default: null
      required:
        - id
        - choices
        - created
        - model
        - object
      title: ChatCompletionChunk
      type: object
    ChatCompletionConfidenceEvent:
      additionalProperties: true
      description: >-
        The confidence event an aligned model adds to its chat stream, with the
        score from 0 to 100.
      properties:
        id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: Identifier of the streamed completion
          title: Id
        object:
          const: confidence
          default: confidence
          description: Always "confidence"
          title: Object
          type: string
        confidence_score:
          description: Confidence score from 0 to 100
          title: Confidence Score
          type: number
      required:
        - confidence_score
      title: ChatCompletionConfidenceEvent
      type: object
    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.
    AnthropicMessage:
      properties:
        role:
          type: string
          enum:
            - user
            - assistant
          title: Role
          description: Who wrote the turn
        content:
          anyOf:
            - type: string
            - items:
                additionalProperties: true
                type: object
              type: array
          title: Content
          description: Text, or a list of content blocks
      type: object
      required:
        - role
        - content
      title: AnthropicMessage
      description: One turn of the conversation.
    AnthropicContentBlock:
      properties:
        type:
          type: string
          const: text
          title: Type
          description: Always "text".
        text:
          type: string
          title: Text
          description: Generated text
      type: object
      required:
        - type
        - text
      title: AnthropicContentBlock
      description: A block of generated content.
    AnthropicUsage:
      properties:
        input_tokens:
          type: integer
          title: Input Tokens
          description: Tokens in the input
        output_tokens:
          type: integer
          title: Output Tokens
          description: Tokens generated
      type: object
      required:
        - input_tokens
        - output_tokens
      title: AnthropicUsage
      description: Token counts for the call.
    Choice:
      additionalProperties: true
      properties:
        delta:
          $ref: '#/components/schemas/ChoiceDelta'
        finish_reason:
          anyOf:
            - enum:
                - stop
                - length
                - tool_calls
                - content_filter
                - function_call
              type: string
            - type: 'null'
          default: null
          title: Finish Reason
        index:
          title: Index
          type: integer
        logprobs:
          anyOf:
            - $ref: '#/components/schemas/ChoiceLogprobs'
            - type: 'null'
          default: null
      required:
        - delta
        - index
      title: Choice
      type: object
      description: One choice of a streamed chunk.
    CompletionUsage:
      additionalProperties: true
      description: Usage statistics for the completion request.
      properties:
        completion_tokens:
          title: Completion Tokens
          type: integer
        prompt_tokens:
          title: Prompt Tokens
          type: integer
        total_tokens:
          title: Total Tokens
          type: integer
        completion_tokens_details:
          anyOf:
            - $ref: '#/components/schemas/CompletionTokensDetails'
            - type: 'null'
          default: null
        prompt_tokens_details:
          anyOf:
            - $ref: '#/components/schemas/PromptTokensDetails'
            - type: 'null'
          default: null
      required:
        - completion_tokens
        - prompt_tokens
        - total_tokens
      title: CompletionUsage
      type: object
    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.
    ChoiceDelta:
      additionalProperties: true
      description: A chat completion delta generated by streamed model responses.
      properties:
        content:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Content
        function_call:
          anyOf:
            - $ref: '#/components/schemas/ChoiceDeltaFunctionCall'
            - type: 'null'
          default: null
        refusal:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Refusal
        role:
          anyOf:
            - enum:
                - developer
                - system
                - user
                - assistant
                - tool
              type: string
            - type: 'null'
          default: null
          title: Role
        tool_calls:
          anyOf:
            - items:
                $ref: '#/components/schemas/ChoiceDeltaToolCall'
              type: array
            - type: 'null'
          default: null
          title: Tool Calls
      title: ChoiceDelta
      type: object
    ChoiceLogprobs:
      additionalProperties: true
      description: Log probability information for the choice.
      properties:
        content:
          anyOf:
            - items:
                $ref: '#/components/schemas/ChatCompletionTokenLogprob'
              type: array
            - type: 'null'
          default: null
          title: Content
        refusal:
          anyOf:
            - items:
                $ref: '#/components/schemas/ChatCompletionTokenLogprob'
              type: array
            - type: 'null'
          default: null
          title: Refusal
      title: ChoiceLogprobs
      type: object
    CompletionTokensDetails:
      additionalProperties: true
      description: Breakdown of tokens used in a completion.
      properties:
        accepted_prediction_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          title: Accepted Prediction Tokens
        audio_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          title: Audio Tokens
        reasoning_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          title: Reasoning Tokens
        rejected_prediction_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          title: Rejected Prediction Tokens
      title: CompletionTokensDetails
      type: object
    PromptTokensDetails:
      additionalProperties: true
      description: Breakdown of tokens used in the prompt.
      properties:
        audio_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          title: Audio Tokens
        cached_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          title: Cached Tokens
      title: PromptTokensDetails
      type: object
    ChoiceDeltaFunctionCall:
      additionalProperties: true
      description: >-
        Deprecated and replaced by `tool_calls`.


        The name and arguments of a function that should be called, as generated
        by the model.
      properties:
        arguments:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Arguments
        name:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Name
      title: ChoiceDeltaFunctionCall
      type: object
    ChoiceDeltaToolCall:
      additionalProperties: true
      properties:
        index:
          title: Index
          type: integer
        id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Id
        function:
          anyOf:
            - $ref: '#/components/schemas/ChoiceDeltaToolCallFunction'
            - type: 'null'
          default: null
        type:
          anyOf:
            - const: function
              type: string
            - type: 'null'
          default: null
          title: Type
      required:
        - index
      title: ChoiceDeltaToolCall
      type: object
      description: A tool call carried by a streamed chunk.
    ChatCompletionTokenLogprob:
      additionalProperties: true
      properties:
        token:
          title: Token
          type: string
        bytes:
          anyOf:
            - items:
                type: integer
              type: array
            - type: 'null'
          default: null
          title: Bytes
        logprob:
          title: Logprob
          type: number
        top_logprobs:
          items:
            $ref: '#/components/schemas/TopLogprob'
          title: Top Logprobs
          type: array
      required:
        - token
        - logprob
        - top_logprobs
      title: ChatCompletionTokenLogprob
      type: object
      description: Log probability of one token.
    ChoiceDeltaToolCallFunction:
      additionalProperties: true
      properties:
        arguments:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Arguments
        name:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Name
      title: ChoiceDeltaToolCallFunction
      type: object
      description: The function name and arguments of a streamed tool call.
    TopLogprob:
      additionalProperties: true
      properties:
        token:
          title: Token
          type: string
        bytes:
          anyOf:
            - items:
                type: integer
              type: array
            - type: 'null'
          default: null
          title: Bytes
        logprob:
          title: Logprob
          type: number
      required:
        - token
        - logprob
      title: TopLogprob
      type: object
      description: One of the most likely tokens at a position, with its log probability.
  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.