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

# Encrypted Chat Completions (RVENC)

> Simple pass-through to enclave chat completion endpoint with encrypted payload. Rvenc = raw volatile encrypted. Accepts a single encrypted inference parameter that encapsulates all chat completion data. Only provides authentication, security checks, and token rate limiting. No chat history, file management, or custom features.

# TypeScript SDK

The SDK is available on GitHub: [premAI-io/api-sdk-ts](https://github.com/premAI-io/api-sdk-ts)

## Usage

### Basic Setup

Create a client with auto-generated encryption keys:

```typescript theme={"system"}
import createRvencClient from "@premai/api-sdk";

const client = await createRvencClient({
  apiKey: process.env.API_KEY,
  clientKEK: process.env.CLIENT_KEK
});
```

### Pre-generate Keys

You can pre-generate encryption keys and reuse them:

```typescript theme={"system"}
import createRvencClient, { generateEncryptionKeys } from "@premai/api-sdk";

const encryptionKeys = await generateEncryptionKeys();

const client = await createRvencClient({
  apiKey: process.env.API_KEY,
  encryptionKeys,
  requestTimeoutMs: 60000,  // optional
  maxBufferSize: 20 * 1024 * 1024, // optional
});
```

### Non-streaming Requests

```typescript theme={"system"}
const response = await client.chat.completions.create({
  model: "openai/gpt-oss-120b",
  messages: [{ role: "user", content: "Hello!" }],
});
```

### Streaming Requests

```typescript theme={"system"}
const stream = await client.chat.completions.create({
  model: "openai/gpt-oss-120b",
  messages: [{ role: "user", content: "Hello!" }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content || "");
}
```

## Configuration

| Option             | Default        | Description                                  |
| ------------------ | -------------- | -------------------------------------------- |
| `apiKey`           | required       | Authorization token                          |
| `encryptionKeys`   | auto-generated | Pre-generated `{ sharedSecret, cipherText }` |
| `requestTimeoutMs` | 30000          | Request timeout in ms                        |
| `maxBufferSize`    | 10MB           | Max SSE buffer size                          |

## OpenAI-Compatible API Server

Run as a standalone server with automatic DEK store management per API key:

```bash theme={"system"}
npm start
# Server runs on http://localhost:3000
```

Use with any OpenAI-compatible client:

```bash theme={"system"}
curl http://localhost:3000/v1/chat/completions \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"model": "openai/gpt-oss-120b", "messages": [{"role": "user", "content": "Hello!"}], "stream": false}'
```

Or use the SDK directly in Node.js:

```typescript theme={"system"}
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.API_KEY,
  baseURL: "http://localhost:3000/v1",
});

const stream = await client.chat.completions.create({
  model: "openai/gpt-oss-120b",
  messages: [{ role: "user", content: "Count to 10" }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content || "");
}
```

The server caches clients in memory per API key for better performance.

***

# API Reference


## OpenAPI

````yaml post /rvenc/chat/completions
openapi: 3.1.0
info:
  title: Prem API
  description: Full description of private and dev-availble API endpoints
  version: 1.0.0
  termsOfService: https://prem.io/terms
  contact:
    name: API Support
    url: https://help.prem.io
    email: support@premai.io
servers:
  - url: https://gateway.prem.io
    description: Production API server
security: []
paths:
  /rvenc/chat/completions:
    post:
      tags:
        - Chats
        - dev-api
      summary: Encrypted Chat Completions (RVENC)
      description: >-
        Simple pass-through to enclave chat completion endpoint with encrypted
        payload. Rvenc = raw volatile encrypted. Accepts a single encrypted
        inference parameter that encapsulates all chat completion data. Only
        provides authentication, security checks, and token rate limiting. No
        chat history, file management, or custom features.
      operationId: createRvencChatCompletion
      requestBody:
        $ref: '#/components/requestBodies/createRvencChatCompletionRequest'
      responses:
        '200':
          $ref: '#/components/responses/createRvencChatCompletionResponse'
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '429':
          description: Too many requests - concurrent stream limit reached
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                    examples:
                      - 429
                  error:
                    type: string
                    examples:
                      - >-
                        You already have an active chat stream. Please wait for
                        it to complete or try again in a few moments.
      security:
        - BearerAuth: []
          ApiKeyAuth: []
components:
  requestBodies:
    createRvencChatCompletionRequest:
      required: true
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/createRvencChatCompletionRequest'
  responses:
    '400':
      description: Bad request
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: integer
                enum:
                  - 400
                  - 401
                  - 403
                  - 404
                description: Status code of the response
              data:
                type:
                  - object
                  - 'null'
                description: Response data containing the requested object
              error:
                type:
                  - string
                  - 'null'
                examples:
                  - Some error message
                description: Error message of the response, human readable
              message:
                type: 'null'
              env:
                type: string
                enum:
                  - development
                  - production
                description: API environment
              log:
                type:
                  - string
                  - object
                  - 'null'
                examples:
                  - request_id: req_1234567890
                  - Some pertinent log message
                description: Useful informaiton, not always present, to debug the response
              validator:
                type:
                  - object
                  - array
                  - 'null'
                examples:
                  - email: Invalid email address
                    password: Password is required
                description: >-
                  Validator response object, each key is the field name and
                  value is the error message
              support_id:
                type:
                  - string
                  - 'null'
                format: uuid
                examples:
                  - support_uuidv7-something-else
                description: >-
                  Support ID linked to the response, used to identify it when
                  talking with our team
            required:
              - status
              - error
              - message
              - env
              - log
              - support_id
            additionalProperties: false
    '401':
      description: Access token is missing or invalid
      content:
        application/json:
          schema:
            allOf:
              - type: object
                properties:
                  status:
                    type: integer
                    enum:
                      - 400
                      - 401
                      - 403
                      - 404
                    description: Status code of the response
                  data:
                    type:
                      - object
                      - 'null'
                    description: Response data containing the requested object
                  error:
                    type:
                      - string
                      - 'null'
                    examples:
                      - Some error message
                    description: Error message of the response, human readable
                  message:
                    type: 'null'
                  env:
                    type: string
                    enum:
                      - development
                      - production
                    description: API environment
                  log:
                    type:
                      - string
                      - object
                      - 'null'
                    examples:
                      - request_id: req_1234567890
                      - Some pertinent log message
                    description: >-
                      Useful informaiton, not always present, to debug the
                      response
                  validator:
                    type:
                      - object
                      - array
                      - 'null'
                    examples:
                      - email: Invalid email address
                        password: Password is required
                    description: >-
                      Validator response object, each key is the field name and
                      value is the error message
                  support_id:
                    type:
                      - string
                      - 'null'
                    format: uuid
                    examples:
                      - support_uuidv7-something-else
                    description: >-
                      Support ID linked to the response, used to identify it
                      when talking with our team
                required:
                  - status
                  - error
                  - message
                  - env
                  - log
                  - support_id
                additionalProperties: false
              - properties:
                  status:
                    type: integer
                    enum:
                      - 401
    '403':
      description: You do not have the required permissions to access this resource
      content:
        application/json:
          schema:
            allOf:
              - type: object
                properties:
                  status:
                    type: integer
                    enum:
                      - 400
                      - 401
                      - 403
                      - 404
                    description: Status code of the response
                  data:
                    type:
                      - object
                      - 'null'
                    description: Response data containing the requested object
                  error:
                    type:
                      - string
                      - 'null'
                    examples:
                      - Some error message
                    description: Error message of the response, human readable
                  message:
                    type: 'null'
                  env:
                    type: string
                    enum:
                      - development
                      - production
                    description: API environment
                  log:
                    type:
                      - string
                      - object
                      - 'null'
                    examples:
                      - request_id: req_1234567890
                      - Some pertinent log message
                    description: >-
                      Useful informaiton, not always present, to debug the
                      response
                  validator:
                    type:
                      - object
                      - array
                      - 'null'
                    examples:
                      - email: Invalid email address
                        password: Password is required
                    description: >-
                      Validator response object, each key is the field name and
                      value is the error message
                  support_id:
                    type:
                      - string
                      - 'null'
                    format: uuid
                    examples:
                      - support_uuidv7-something-else
                    description: >-
                      Support ID linked to the response, used to identify it
                      when talking with our team
                required:
                  - status
                  - error
                  - message
                  - env
                  - log
                  - support_id
                additionalProperties: false
              - properties:
                  status:
                    type: integer
                    enum:
                      - 403
    createRvencChatCompletionResponse:
      description: >-
        Server-sent events stream with encrypted OpenAI-compatible chat
        completion chunks. Each chunk in the stream is encrypted and must be
        decrypted using the same shared secret and nonce from the request.
      content:
        text/event-stream:
          schema:
            $ref: '#/components/schemas/createRvencChatCompletionResponse'
  schemas:
    createRvencChatCompletionRequest:
      type: object
      description: >-
        Request body for rvenc (raw volatile encrypted) chat completion.
        Contains an encrypted payload with cryptographic materials needed for
        decryption.
      properties:
        encryptedInference:
          type: string
          description: >-
            Encrypted JSON string containing all chat completion parameters.
            When decrypted, this string must match the structure shown in the
            expandable `_decryptedInference` property below (reference only - do
            not send this property).
        _decryptedInference:
          $ref: '#/components/schemas/rvencInferenceParams'
          description: >-
            **Reference only - Do NOT send this property** - This shows the
            structure that `encryptedInference` should contain when decrypted.
            Encrypt a JSON object matching this structure and send it as the
            `encryptedInference` string.
          readOnly: true
        cipherText:
          type: string
          description: Cipher text for shared secret generation (ECDH key exchange)
        nonce:
          type: string
          description: Nonce used for encrypting the inference payload
      required:
        - encryptedInference
        - cipherText
        - nonce
      additionalProperties: false
      examples:
        - encryptedInference: encrypted_inference_payload_data
          cipherText: cipher_text_for_key_exchange
          nonce: nonce_value
    createRvencChatCompletionResponse:
      type: object
      description: >-
        Server-sent events (SSE) stream response structure. The actual response
        is a text stream, but this schema documents the structure for reference.
      properties:
        stream:
          type: string
          description: >-
            Server-sent events (SSE) stream with encrypted chat completion
            chunks. The stream contains three types of events:

            - `event: data` followed by `data: <encrypted_hex_string>` -
            Encrypted chunk that must be decrypted using the same shared secret
            and nonce from the request. When decrypted, each chunk matches the
            structure shown in the `_decryptedChunk` property below (reference
            only).

            - `event: error` followed by `data: <error_data>` - Error event (can
            be encrypted or plain JSON)

            - `event: done` followed by `data: [DONE]` - Stream completion
            marker


            Each encrypted `data:` line contains a hex-encoded string. Decrypt
            each chunk using XChaCha20-Poly1305 with the shared secret and nonce
            from your request.
        _decryptedChunk:
          $ref: '#/components/schemas/rvencChatCompletionChunk'
          description: >-
            **Reference only** - This shows the structure that each encrypted
            chunk should contain when decrypted. Decrypt each chunk in the
            stream using the same shared secret and nonce from your request to
            get this structure.
          readOnly: true
      required:
        - stream
      examples:
        - stream: |-
            event: data
            data: a1b2c3d4e5f67890abcdef1234567890abcdef123456...

            event: data
            data: f6e5d4c3b2a19876543210fedcba9876543210fedcba...

            event: data
            data: 1234567890abcdef1234567890abcdef1234567890...

            event: done
            data: [DONE]
        - stream: |-
            event: data
            data: a1b2c3d4e5f67890abcdef1234567890abcdef123456...

            event: error
            data: {"error":{"message":"Error occurred","type":"api_error"}}

            event: done
            data: [DONE]
    rvencInferenceParams:
      type: object
      description: >-
        Decrypted inference parameters that are encrypted and sent as
        encryptedInference. This schema documents the structure of the JSON that
        should be encrypted and included in the encryptedInference field.
      properties:
        messages:
          type: array
          description: >-
            A list of messages comprising the conversation so far. Depending on
            the model you use, different message types (modalities) are
            supported, like text, images, and audio.
          items:
            oneOf:
              - type: object
                description: >-
                  Developer-provided instructions that the model should follow.
                  With o1 models and newer, use developer messages for this
                  purpose instead.
                properties:
                  role:
                    type: string
                    enum:
                      - system
                    description: The role of the messages author, in this case system
                  content:
                    oneOf:
                      - type: string
                        description: The contents of the system message
                      - type: array
                        description: >-
                          An array of content parts with a defined type. For
                          system messages, only type text is supported
                        items:
                          type: object
                          properties:
                            text:
                              type: string
                              description: The text content
                            type:
                              type: string
                              enum:
                                - text
                              description: The type of the content part
                          required:
                            - text
                            - type
                    description: The contents of the system message
                  name:
                    type: string
                    description: >-
                      An optional name for the participant. Provides the model
                      information to differentiate between participants of the
                      same role
                required:
                  - role
                  - content
              - type: object
                description: >-
                  Messages sent by an end user, containing prompts or additional
                  context information
                properties:
                  role:
                    type: string
                    enum:
                      - user
                    description: The role of the messages author, in this case user
                  content:
                    oneOf:
                      - type: string
                        description: The text contents of the message
                      - type: array
                        description: >-
                          An array of content parts with a defined type.
                          Supported options differ based on the model being used
                          to generate the response. Can contain text, image, or
                          audio inputs
                        items:
                          oneOf:
                            - type: object
                              properties:
                                text:
                                  type: string
                                  description: The text content
                                type:
                                  type: string
                                  enum:
                                    - text
                                  description: The type of the content part
                              required:
                                - text
                                - type
                            - type: object
                              properties:
                                image_url:
                                  type: object
                                  properties:
                                    url:
                                      type: string
                                      description: >-
                                        Either a URL of the image or the base64
                                        encoded image data
                                    detail:
                                      type: string
                                      enum:
                                        - low
                                        - high
                                        - auto
                                      default: auto
                                      description: Specifies the detail level of the image
                                  required:
                                    - url
                                type:
                                  type: string
                                  enum:
                                    - image_url
                                  description: The type of the content part
                              required:
                                - image_url
                                - type
                            - type: object
                              properties:
                                input_audio:
                                  type: object
                                  properties:
                                    data:
                                      type: string
                                      description: Base64 encoded audio data
                                    format:
                                      type: string
                                      enum:
                                        - wav
                                        - mp3
                                      description: The format of the encoded audio data
                                  required:
                                    - data
                                    - format
                                type:
                                  type: string
                                  enum:
                                    - input_audio
                                  description: >-
                                    The type of the content part. Always
                                    input_audio
                              required:
                                - input_audio
                                - type
                            - type: object
                              properties:
                                file:
                                  type: object
                                  properties:
                                    file_data:
                                      type: string
                                      description: >-
                                        The base64 encoded file data, used when
                                        passing the file to the model as a
                                        string
                                    file_id:
                                      type: string
                                      description: >-
                                        The ID of an uploaded file to use as
                                        input
                                    filename:
                                      type: string
                                      description: >-
                                        The name of the file, used when passing
                                        the file to the model as a string
                                type:
                                  type: string
                                  enum:
                                    - file
                                  description: The type of the content part. Always file
                              required:
                                - file
                                - type
                    description: The contents of the user message
                  name:
                    type: string
                    description: >-
                      An optional name for the participant. Provides the model
                      information to differentiate between participants of the
                      same role
                required:
                  - role
                  - content
              - type: object
                description: Messages sent by the model in response to user messages
                properties:
                  role:
                    type: string
                    enum:
                      - assistant
                    description: The role of the messages author, in this case assistant
                  audio:
                    type: object
                    properties:
                      id:
                        type: string
                        description: >-
                          Unique identifier for a previous audio response from
                          the model
                    required:
                      - id
                    description: Data about a previous audio response from the model
                  content:
                    oneOf:
                      - type: string
                      - type: array
                        items:
                          type: object
                          properties:
                            text:
                              type: string
                              description: The text content
                            type:
                              type: string
                              enum:
                                - text
                              description: The type of the content part
                          required:
                            - text
                            - type
                    description: >-
                      The contents of the assistant message. Required unless
                      tool_calls or function_call is specified
                  function_call:
                    type: object
                    properties:
                      name:
                        type: string
                        description: The name of the function to call
                      arguments:
                        type: string
                        description: >-
                          The arguments to call the function with, as generated
                          by the model in JSON format
                    required:
                      - name
                      - arguments
                    description: >-
                      Deprecated and replaced by tool_calls. The name and
                      arguments of a function that should be called, as
                      generated by the model
                  name:
                    type: string
                    description: >-
                      An optional name for the participant. Provides the model
                      information to differentiate between participants of the
                      same role
                  refusal:
                    type: string
                    description: The refusal message by the assistant
                  tool_calls:
                    type: array
                    description: >-
                      The tool calls generated by the model, such as function
                      calls
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          description: Unique identifier for the tool call
                        type:
                          type: string
                          description: Type of tool call
                        function:
                          type: object
                          properties:
                            name:
                              type: string
                              description: Name of the function to call
                            arguments:
                              type: string
                              description: JSON string of function arguments
                          required:
                            - name
                            - arguments
                      required:
                        - id
                        - type
                        - function
                required:
                  - role
              - type: object
                description: Tool message
                properties:
                  role:
                    type: string
                    enum:
                      - tool
                    description: The role of the messages author, in this case tool
                  content:
                    oneOf:
                      - type: string
                        description: The contents of the tool message
                      - type: array
                        description: >-
                          An array of content parts with a defined type. For
                          tool messages, only type text is supported
                        items:
                          type: object
                          properties:
                            text:
                              type: string
                              description: The text content
                            type:
                              type: string
                              enum:
                                - text
                              description: The type of the content part
                          required:
                            - text
                            - type
                    description: The contents of the tool message
                  tool_call_id:
                    type: string
                    description: Tool call that this message is responding to
                required:
                  - role
                  - content
                  - tool_call_id
              - type: object
                description: Deprecated function message
                properties:
                  role:
                    type: string
                    enum:
                      - function
                    description: The role of the messages author, in this case function
                  content:
                    type: string
                    description: The contents of the function message
                  name:
                    type: string
                    description: The name of the function to call
                required:
                  - role
                  - content
                  - name
          minItems: 1
        model:
          type: string
          description: The model identifier to use for completion
        temperature:
          type: number
          minimum: 0
          maximum: 2
          description: >-
            Sampling temperature between 0 and 2. Higher values make output more
            random.
        top_p:
          type: number
          minimum: 0
          maximum: 1
          description: >-
            Nucleus sampling parameter. Consider tokens with top_p probability
            mass.
        max_tokens:
          type:
            - integer
            - 'null'
          description: >-
            The maximum number of tokens that can be generated in the chat
            completion. This value can be used to control costs for text
            generated via API. This value is now deprecated in favor of
            max_completion_tokens, and is not compatible with o-series models
        max_completion_tokens:
          type:
            - integer
            - 'null'
          description: >-
            An upper bound for the number of tokens that can be generated for a
            completion, including visible output tokens and reasoning tokens
        stream:
          type:
            - boolean
            - 'null'
          default: false
          description: >-
            If set to true, the model response data will be streamed to the
            client as it is generated using server-sent events
        tools:
          type: array
          description: >-
            A list of tools the model may call. You can provide either custom
            tools or function tools
          items:
            oneOf:
              - type: object
                description: A function tool that can be used to generate a response
                properties:
                  type:
                    type: string
                    enum:
                      - function
                    description: >-
                      The type of the tool. Currently, only function is
                      supported
                  function:
                    type: object
                    properties:
                      name:
                        type: string
                        description: >-
                          The name of the function to be called. Must be a-z,
                          A-Z, 0-9, or contain underscores and dashes, with a
                          maximum length of 64
                      description:
                        type: string
                        description: >-
                          A description of what the function does, used by the
                          model to choose when and how to call the function
                      parameters:
                        type: object
                        description: >-
                          The parameters the functions accepts, described as a
                          JSON Schema object. Omitting parameters defines a
                          function with an empty parameter list
                    required:
                      - name
                required:
                  - type
                  - function
              - type: object
                description: A custom tool that processes input using a specified format
                properties:
                  type:
                    type: string
                    enum:
                      - custom
                    description: The type of the custom tool. Always custom
                  custom:
                    type: object
                    properties:
                      name:
                        type: string
                        description: >-
                          The name of the custom tool, used to identify it in
                          tool calls
                      description:
                        type: string
                        description: >-
                          Optional description of the custom tool, used to
                          provide more context
                      format:
                        type: object
                        description: >-
                          The input format for the custom tool. Default is
                          unconstrained text
                    required:
                      - name
                    description: Properties of the custom tool
                required:
                  - type
                  - custom
        tool_choice:
          oneOf:
            - type: string
              enum:
                - none
                - auto
                - required
              description: >-
                none means the model will not call any tool and instead
                generates a message. auto means the model can pick between
                generating a message or calling one or more tools. required
                means the model must call one or more tools
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - function
                  description: For function calling, the type is always function
                function:
                  type: object
                  properties:
                    name:
                      type: string
                      description: The name of the function to call
                  required:
                    - name
              required:
                - type
                - function
              description: >-
                Specifies a tool the model should use. Use to force the model to
                call a specific function
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - custom
                  description: For custom tool calling, the type is always custom
                custom:
                  type: object
                  properties:
                    name:
                      type: string
                      description: The name of the custom tool to call
                  required:
                    - name
              required:
                - type
                - custom
              description: >-
                Specifies a tool the model should use. Use to force the model to
                call a specific custom tool
          description: >-
            Controls which (if any) tool is called by the model. none means the
            model will not call any tool and instead generates a message. auto
            means the model can pick between generating a message or calling one
            or more tools. required means the model must call one or more tools.
            Specifying a particular tool forces the model to call that tool
        response_format:
          oneOf:
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - text
                  description: The type of response format being defined. Always text
              required:
                - type
              description: Default response format. Used to generate text responses
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - json_schema
                  description: >-
                    The type of response format being defined. Always
                    json_schema
                json_schema:
                  type: object
                  properties:
                    name:
                      type: string
                      description: >-
                        The name of the response format. Must be a-z, A-Z, 0-9,
                        or contain underscores and dashes, with a maximum length
                        of 64
                    description:
                      type: string
                      description: >-
                        A description of what the response format is for, used
                        by the model to determine how to respond in the format
                    schema:
                      type: object
                      description: >-
                        The schema for the response format, described as a JSON
                        Schema object
                    strict:
                      type: boolean
                      default: false
                      description: >-
                        Whether to enable strict schema adherence when
                        generating the output. If set to true, the model will
                        always follow the exact schema defined in the schema
                        field
                  required:
                    - name
                  description: >-
                    Structured Outputs configuration options, including a JSON
                    Schema
              required:
                - type
                - json_schema
              description: >-
                JSON Schema response format. Used to generate structured JSON
                responses
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - json_object
                  description: >-
                    The type of response format being defined. Always
                    json_object
              required:
                - type
              description: >-
                JSON object response format. An older method of generating JSON
                responses. Using json_schema is recommended for models that
                support it
          description: An object specifying the format that the model must output
        audio:
          type:
            - object
            - 'null'
          description: >-
            Parameters for audio output. Required when audio output is requested
            with modalities: ["audio"]
          properties:
            format:
              type: string
              enum:
                - wav
                - mp3
                - flac
                - opus
                - pcm16
              description: Specifies the output audio format
            voice:
              type: string
              enum:
                - alloy
                - ash
                - ballad
                - coral
                - echo
                - fable
                - nova
                - onyx
                - sage
                - shimmer
              description: The voice the model uses to respond
          required:
            - format
            - voice
        frequency_penalty:
          type:
            - number
            - 'null'
          default: 0
          minimum: -2
          maximum: 2
          description: >-
            Number between -2.0 and 2.0. Positive values penalize new tokens
            based on their existing frequency in the text so far, decreasing the
            model's likelihood to repeat the same line verbatim
        function_call:
          oneOf:
            - type: string
              enum:
                - none
                - auto
              description: >-
                none means the model will not call a function and instead
                generates a message. auto means the model can pick between
                generating a message or calling a function
            - type: object
              properties:
                name:
                  type: string
                  description: The name of the function to call
              required:
                - name
              description: >-
                Specifying a particular function via {"name": "my_function"}
                forces the model to call that function
          description: >-
            Deprecated in favor of tool_choice. Controls which (if any) function
            is called by the model
        functions:
          type: array
          description: >-
            Deprecated in favor of tools. A list of functions the model may
            generate JSON inputs for
          items:
            type: object
            properties:
              name:
                type: string
                description: >-
                  The name of the function to be called. Must be a-z, A-Z, 0-9,
                  or contain underscores and dashes, with a maximum length of 64
              description:
                type: string
                description: >-
                  A description of what the function does, used by the model to
                  choose when and how to call the function
              parameters:
                type: object
                description: >-
                  The parameters the functions accepts, described as a JSON
                  Schema object. Omitting parameters defines a function with an
                  empty parameter list
            required:
              - name
        logit_bias:
          type: object
          additionalProperties:
            type: number
            minimum: -100
            maximum: 100
          description: >-
            Modify the likelihood of specified tokens appearing in the
            completion. Accepts a JSON object that maps tokens (specified by
            their token ID in the tokenizer) to an associated bias value from
            -100 to 100
        logprobs:
          type:
            - boolean
            - 'null'
          default: false
          description: >-
            Whether to return log probabilities of the output tokens or not. If
            true, returns the log probabilities of each output token returned in
            the content of message
        metadata:
          type: object
          additionalProperties:
            type: string
            maxLength: 512
          maxProperties: 16
          description: >-
            Set of 16 key-value pairs that can be attached to an object. Keys
            are strings with a maximum length of 64 characters. Values are
            strings with a maximum length of 512 characters
        modalities:
          type: array
          description: Output types that you would like the model to generate
          items:
            type: string
            enum:
              - text
              - audio
          default:
            - text
        'n':
          type:
            - integer
            - 'null'
          default: 1
          minimum: 1
          description: >-
            How many chat completion choices to generate for each input message.
            Note that you will be charged based on the number of generated
            tokens across all of the choices. Keep n as 1 to minimize costs
        prediction:
          type: object
          description: >-
            Configuration for a Predicted Output, which can greatly improve
            response times when large parts of the model response are known
            ahead of time
          properties:
            type:
              type: string
              enum:
                - content
              description: >-
                The type of the predicted content you want to provide. This type
                is currently always content
            content:
              oneOf:
                - type: string
                  description: >-
                    The content used for a Predicted Output. This is often the
                    text of a file you are regenerating with minor changes
                - type: array
                  description: >-
                    An array of content parts with a defined type. Supported
                    options differ based on the model being used to generate the
                    response. Can contain text inputs
                  items:
                    type: object
                    properties:
                      text:
                        type: string
                        description: The text content
                      type:
                        type: string
                        enum:
                          - text
                        description: The type of the content part
                    required:
                      - text
                      - type
              description: >-
                The content that should be matched when generating a model
                response
          required:
            - type
            - content
        presence_penalty:
          type:
            - number
            - 'null'
          default: 0
          minimum: -2
          maximum: 2
          description: >-
            Number between -2.0 and 2.0. Positive values penalize new tokens
            based on whether they appear in the text so far, increasing the
            model's likelihood to talk about new topics
        prompt_cache_key:
          type: string
          description: >-
            Used by OpenAI to cache responses for similar requests to optimize
            your cache hit rates. Replaces the user field
        prompt_cache_retention:
          type: string
          description: >-
            The retention policy for the prompt cache. Set to 24h to enable
            extended prompt caching, which keeps cached prefixes active for
            longer, up to a maximum of 24 hours
        reasoning_effort:
          type: string
          enum:
            - none
            - minimal
            - low
            - medium
            - high
          default: medium
          description: >-
            Constrains effort on reasoning for reasoning models. Currently
            supported values are none, minimal, low, medium, and high. Reducing
            reasoning effort can result in faster responses and fewer tokens
            used on reasoning in a response
        safety_identifier:
          type: string
          description: >-
            A stable identifier used to help detect users of your application
            that may be violating OpenAI's usage policies. The IDs should be a
            string that uniquely identifies each user
        seed:
          type:
            - integer
            - 'null'
          description: >-
            This feature is in Beta. If specified, our system will make a best
            effort to sample deterministically, such that repeated requests with
            the same seed and parameters should return the same result.
            Determinism is not guaranteed
        service_tier:
          type: string
          enum:
            - auto
            - default
            - flex
            - priority
          default: auto
          description: Specifies the processing type used for serving the request
        stop:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
              maxItems: 4
            - type: 'null'
          default: null
          description: >-
            Up to 4 sequences where the API will stop generating further tokens.
            The returned text will not contain the stop sequence. Not supported
            with latest reasoning models o3 and o4-mini
        store:
          type:
            - boolean
            - 'null'
          default: false
          description: >-
            Whether or not to store the output of this chat completion request
            for use in our model distillation or evals products. Supports text
            and image inputs. Note: image inputs over 8MB will be dropped
        stream_options:
          type: object
          description: >-
            Options for streaming response. Only set this when you set stream:
            true
          properties:
            include_obfuscation:
              type: boolean
              description: >-
                When true, stream obfuscation will be enabled. Stream
                obfuscation adds random characters to an obfuscation field on
                streaming delta events to normalize payload sizes as a
                mitigation to certain side-channel attacks
            include_usage:
              type: boolean
              description: >-
                If set, an additional chunk will be streamed before the data:
                [DONE] message. The usage field on this chunk shows the token
                usage statistics for the entire request
        top_logprobs:
          type: integer
          minimum: 0
          maximum: 20
          description: >-
            An integer between 0 and 20 specifying the number of most likely
            tokens to return at each token position, each with an associated log
            probability
        verbosity:
          type: string
          enum:
            - low
            - medium
            - high
          default: medium
          description: >-
            Constrains the verbosity of the model's response. Lower values will
            result in more concise responses, while higher values will result in
            more verbose responses
        web_search_options:
          type: object
          description: This tool searches the web for relevant results to use in a response
          properties:
            search_context_size:
              type: string
              enum:
                - low
                - medium
                - high
              default: medium
              description: >-
                High level guidance for the amount of context window space to
                use for the search
            user_location:
              oneOf:
                - type: object
                  properties:
                    approximate:
                      type: object
                      properties:
                        city:
                          type: string
                          description: >-
                            Free text input for the city of the user, e.g. San
                            Francisco
                        country:
                          type: string
                          description: The two-letter ISO country code of the user, e.g. US
                        region:
                          type: string
                          description: >-
                            Free text input for the region of the user, e.g.
                            California
                        timezone:
                          type: string
                          description: >-
                            The IANA timezone of the user, e.g.
                            America/Los_Angeles
                    type:
                      type: string
                      enum:
                        - approximate
                      description: The type of location approximation. Always approximate
                  required:
                    - approximate
                    - type
                - type: 'null'
              description: Approximate location parameters for the search
      required:
        - messages
        - model
      additionalProperties: false
      examples:
        - messages:
            - role: user
              content: Hello, how are you?
          model: openai/gpt-oss-120b
          temperature: 0.7
          stream: true
        - messages:
            - role: system
              content: You are a helpful assistant.
            - role: user
              content: What's the weather like?
          model: openai/gpt-oss-120b
          temperature: 0.8
          top_p: 0.9
          max_tokens: 500
          stream: true
          tools:
            - type: function
              function:
                name: get_weather
                description: Get the current weather for a location
                parameters:
                  type: object
                  properties:
                    location:
                      type: string
                      description: The city and state, e.g. San Francisco, CA
                  required:
                    - location
          tool_choice: auto
    rvencChatCompletionChunk:
      type: object
      description: >-
        Decrypted chat completion chunk structure that matches OpenAI's
        streaming format. Each encrypted chunk in the SSE stream, when
        decrypted, matches this structure.
      properties:
        id:
          type: string
          description: >-
            A unique identifier for the chat completion. Each chunk has the same
            id.
          examples:
            - cd9d05b657a041a6a14ab2fc890a7d7e
        object:
          type: string
          enum:
            - chat.completion.chunk
          description: The object type, which is always 'chat.completion.chunk'
          examples:
            - chat.completion.chunk
        created:
          type: integer
          description: >-
            The Unix timestamp (in seconds) of when the chat completion was
            created
          examples:
            - 1764004858
        model:
          type: string
          description: The model used for the chat completion
          examples:
            - openai/gpt-oss-120b
        system_fingerprint:
          type:
            - string
            - 'null'
          description: >-
            This fingerprint represents the backend configuration that the model
            runs with (optional)
          examples:
            - fp_44709d6fcb
        choices:
          type: array
          description: >-
            A list of chat completion choices. Can contain more than one element
            if n is greater than 1.
          items:
            type: object
            properties:
              index:
                type: integer
                description: The index of the choice in the list of choices
                examples:
                  - 0
              delta:
                type: object
                description: >-
                  A chat completion delta generated by streamed model responses.
                  The delta can contain 'role', 'content', 'reasoning_content',
                  'tool_calls', or be empty {} when finish_reason is set.
                properties:
                  role:
                    type:
                      - string
                      - 'null'
                    enum:
                      - assistant
                      - null
                    description: >-
                      The role of the author of this message (only present in
                      first chunk, can be null)
                    examples:
                      - assistant
                  content:
                    type:
                      - string
                      - 'null'
                    description: >-
                      The contents of the chunk message (can be null or empty
                      string)
                    examples:
                      - Hello
                  reasoning_content:
                    type:
                      - string
                      - 'null'
                    description: >-
                      Reasoning content for models that support reasoning
                      (optional, can be null)
                    examples:
                      - ':'
                  tool_calls:
                    type:
                      - array
                      - 'null'
                    description: Tool calls made by the assistant (optional, can be null)
                    items:
                      type: object
              logprobs:
                type:
                  - object
                  - 'null'
                description: Log probability information for the choice
                default: null
              finish_reason:
                type:
                  - string
                  - 'null'
                enum:
                  - stop
                  - length
                  - tool_calls
                  - content_filter
                  - null
                description: >-
                  The reason the model stopped generating tokens. This will be
                  null if the model hasn't finished generating the tokens yet.
                examples:
                  - stop
              matched_stop:
                type:
                  - string
                  - 'null'
                description: The stop sequence that was matched (optional, can be null)
                default: null
            required:
              - index
              - delta
              - logprobs
              - finish_reason
        usage:
          type:
            - object
            - 'null'
          description: Usage statistics for the completion (optional, can be null)
          properties:
            prompt_tokens:
              type: integer
              description: Number of tokens in the prompt
            completion_tokens:
              type: integer
              description: Number of tokens in the completion
            total_tokens:
              type: integer
              description: Total number of tokens used
          default: null
        error:
          type: object
          description: Error object if an error occurred (optional)
          properties:
            message:
              type: string
              description: Error message
            type:
              type: string
              description: Error type
      required:
        - id
        - object
        - created
        - model
        - choices
      additionalProperties: false
      examples:
        - id: cd9d05b657a041a6a14ab2fc890a7d7e
          object: chat.completion.chunk
          created: 1764004858
          model: openai/gpt-oss-120b
          choices:
            - index: 0
              delta:
                role: null
                content: null
                reasoning_content: 'This '
                tool_calls: null
              logprobs: null
              finish_reason: null
              matched_stop: null
          usage: null
        - id: cd9d05b657a041a6a14ab2fc890a7d7e
          object: chat.completion.chunk
          created: 1764004858
          model: openai/gpt-oss-120b
          choices:
            - index: 0
              delta:
                role: assistant
                content: Hello
                reasoning_content: null
                tool_calls: null
              logprobs: null
              finish_reason: null
              matched_stop: null
          usage: null
        - id: cd9d05b657a041a6a14ab2fc890a7d7e
          object: chat.completion.chunk
          created: 1764004858
          model: openai/gpt-oss-120b
          choices:
            - index: 0
              delta: []
              logprobs: null
              finish_reason: stop
              matched_stop: null
          usage: null
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'Send your access token as header Authorization: Bearer {accessToken}'
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Your API key that starts with sk_live or sk_test. You can create yours
        at go.prem.io/api-keys.

````