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

# Weights sync

> Submits a weights-sync operation that makes the session's current trained parameters available for sampling. Call this after `optim-step` when you want subsequent samples to use the updated policy.



## OpenAPI

````yaml openapi.yaml POST /rl/training-sessions/{session_id}/operations/weights-sync
openapi: 3.1.0
info:
  title: Together APIs
  description: The Together REST API. See https://docs.together.ai for more details.
  version: 2.0.0
  termsOfService: https://www.together.ai/terms-of-service
  contact:
    name: Together Support
    url: https://www.together.ai/contact
  license:
    name: MIT
    url: https://github.com/togethercomputer/openapi/blob/main/LICENSE
servers:
  - url: https://api.together.ai/v1
    description: Default environment for APIs
  - url: https://api-inference.together.ai/v2
    description: Optimized environment for inference
security:
  - bearerAuth: []
paths:
  /rl/training-sessions/{session_id}/operations/weights-sync:
    post:
      tags:
        - RL
      summary: Weights sync
      description: >-
        Submits a weights-sync operation that makes the session's current
        trained parameters available for sampling. Call this after `optim-step`
        when you want subsequent samples to use the updated policy.
      operationId: WeightsSync
      parameters:
        - name: session_id
          in: path
          required: true
          schema:
            description: Training session ID
            type: string
        - name: Idempotency-Key
          in: header
          required: true
          schema:
            description: >-
              Required key that makes retries return the original operation; use
              a new key for changed request bodies.
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RL.WeightsSyncBody'
        required: true
      responses:
        '200':
          description: Weights-sync operation details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RL.WeightsSyncOperation'
        default:
          description: An unexpected error response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorData'
components:
  schemas:
    RL.WeightsSyncBody:
      type: object
      description: Request body for publishing updated policy parameters for sampling.
      required:
        - weight_sync_type
      properties:
        weight_sync_type:
          $ref: '#/components/schemas/RL.WeightSyncType'
          description: >-
            How updated parameters are made available for sampling. See
            `WeightSyncType` for accepted values.
    RL.WeightsSyncOperation:
      type: object
      description: Async weights-sync operation
      required:
        - id
        - status
      properties:
        id:
          type: string
          example: 550e8400-e29b-41d4-a716-446655440000
          description: Operation ID
        status:
          $ref: '#/components/schemas/RL.TrainingOperationStatus'
          description: Operation status
        output:
          $ref: '#/components/schemas/RL.WeightsSyncResult'
          description: Result on success
        error:
          $ref: '#/components/schemas/RL.TrainingOperationError'
          description: Error details on failure
    ErrorData:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              nullable: false
            type:
              type: string
              nullable: false
            param:
              type: string
              nullable: true
              default: null
            code:
              type: string
              nullable: true
              default: null
          required:
            - type
            - message
    RL.WeightSyncType:
      type: string
      description: >-
        How updated policy parameters are made available for sampling.
        SYNCHRONOUS waits for the policy update before returning;
        BACKGROUND_PUBLISH returns after scheduling the update; PIPELINE
        overlaps the update with in-flight sampling when possible.
      enum:
        - WEIGHT_SYNC_TYPE_SYNCHRONOUS
        - WEIGHT_SYNC_TYPE_BACKGROUND_PUBLISH
        - WEIGHT_SYNC_TYPE_PIPELINE
    RL.TrainingOperationStatus:
      type: string
      enum:
        - TRAINING_OPERATION_STATUS_UNSPECIFIED
        - TRAINING_OPERATION_STATUS_PENDING
        - TRAINING_OPERATION_STATUS_RUNNING
        - TRAINING_OPERATION_STATUS_COMPLETED
        - TRAINING_OPERATION_STATUS_FAILED
      default: TRAINING_OPERATION_STATUS_UNSPECIFIED
    RL.WeightsSyncResult:
      type: object
      description: Result of a weights-sync operation
      required:
        - weights_version
      properties:
        weights_version:
          description: >-
            Policy version now available for sampling, or queued to become
            available for deferred sync modes. Comparable to
            `policy_segments[].version` on sample results.
          oneOf:
            - type: string
            - type: integer
          example: '100'
    RL.TrainingOperationError:
      type: object
      description: Error details for a failed training operation
      properties:
        code:
          $ref: '#/components/schemas/RL.TrainingOperationErrorCode'
          description: Application error code
          example: TRAINING_OPERATION_ERROR_CODE_TIMEOUT
        message:
          description: Human-readable error message
          type: string
          example: Operation timed out
    RL.TrainingOperationErrorCode:
      type: string
      description: Application error code for a failed training operation
      enum:
        - TRAINING_OPERATION_ERROR_CODE_UNSPECIFIED
        - TRAINING_OPERATION_ERROR_CODE_RESOURCE_EXHAUSTED
        - TRAINING_OPERATION_ERROR_CODE_TIMEOUT
        - TRAINING_OPERATION_ERROR_CODE_INTERNAL_ERROR
        - TRAINING_OPERATION_ERROR_CODE_SESSION_NOT_ACTIVE
        - TRAINING_OPERATION_ERROR_CODE_INVALID_INPUT
        - TRAINING_OPERATION_ERROR_CODE_NON_FINITE_LOSS
      default: TRAINING_OPERATION_ERROR_CODE_UNSPECIFIED
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      x-bearer-format: bearer
      x-default: default

````

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