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

# Create Environment

> 创建新的环境实例



## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/agentlin/openapi.documented.yml post /env/create
openapi: 3.1.0
info:
  title: Agentlin API
  description: >-
    The Agentlin REST API. Please see https://linxueyuan.online/agentlin/ for
    more details.
  version: 2.3.0
  termsOfService: https://linxueyuan.online/policies/terms-of-use
  contact:
    name: Agentlin Support
    url: https://help.linxueyuan.online/
  license:
    name: MIT
    url: https://github.com/LinXueyuanStdio/agentlin/blob/master/LICENSE
servers:
  - url: https://api.linxueyuan.online/v1
security:
  - ApiKeyAuth: []
tags:
  - name: Tasks
    description: Create, retrieve, and cancel agent tasks.
  - name: Environment
    description: Interact with remote environments.
paths:
  /env/create:
    post:
      tags:
        - Environment
      summary: Create Environment
      description: 创建新的环境实例
      operationId: create_environment_v1_env_create_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EnvCreateRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnvCreateResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Client from 'agentlin_client';

            const client = new Client({
              apiKey: process.env['AGENTLIN_API_KEY'], // This is the default and can be omitted
            });

            const env = await client.env.create();

            console.log(env.env_id);
        - lang: Python
          source: |-
            import os
            from agentlin_client import Client

            client = Client(
                api_key=os.environ.get("AGENTLIN_API_KEY"),  # This is the default and can be omitted
            )
            env = client.env.create()
            print(env.env_id)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/LinXueyuanStdio/agentlin-client-go\"\n\t\"github.com/LinXueyuanStdio/agentlin-client-go/option\"\n)\n\nfunc main() {\n\tclient := agentlin.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tenv, err := client.Env.New(context.TODO(), agentlin.EnvNewParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", env.EnvID)\n}\n"
components:
  schemas:
    EnvCreateRequest:
      properties:
        session_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Session Id
        env_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Env Id
        user_id:
          anyOf:
            - type: string
            - type: 'null'
          title: User Id
        client_id:
          type: string
          title: Client Id
          default: default
        env_vars:
          anyOf:
            - additionalProperties:
                type: string
              type: object
            - type: 'null'
          title: Env Vars
        env_class_path:
          anyOf:
            - type: string
            - type: 'null'
          title: Env Class Path
        env_init_kwargs:
          anyOf:
            - type: object
              additionalProperties: true
            - type: 'null'
          title: Env Init Kwargs
      type: object
      title: EnvCreateRequest
      description: 创建环境请求
    EnvCreateResponse:
      properties:
        session_id:
          type: string
          title: Session Id
        env_id:
          type: string
          title: Env Id
        initial_state:
          additionalProperties: true
          type: object
          title: Initial State
        tools:
          items:
            $ref: '#/components/schemas/ToolData'
          type: array
          title: Tools
        done:
          type: boolean
          title: Done
          default: false
      type: object
      required:
        - session_id
        - env_id
        - initial_state
        - tools
      title: EnvCreateResponse
      description: 创建环境响应
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ToolData:
      type: object
      properties:
        type:
          type: string
          enum:
            - function
          default: function
          description: 工具类型，此处固定为 function。
        function:
          $ref: '#/components/schemas/FunctionDefinition'
          description: 函数工具定义（名称/参数/描述）。
      required:
        - type
        - function
    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
    FunctionDefinition:
      type: object
      properties:
        name:
          type: string
          description: 工具/函数名称（唯一标识）。
        description:
          type: string
          description: 函数的用途说明。
        parameters:
          type: object
          description: JSON Schema for the function parameters.
          additionalProperties: true
        strict:
          type: boolean
          default: false
          description: 是否启用严格参数校验。
      required:
        - name
        - parameters
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer

````