Environments

The /environments endpoint allows you to manage your Environments.

List Environments

Endpoint: /environments

Method: GET

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>

Query Parameters

ParameterData TypeDescription
allbooleanIf true, list all environments, otherwise only the ones for the current project

Example Request

curl --location --request GET 'https://studio-server-production.api.becomposable.com/api/v1/environments?all=true' \
--header 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Example Response

[
  {
    "id": "<ENVIRONMENT_ID>",
    "name": "My OpenAI Environment",
    "provider": "openai",
    "created_at": "2023-10-26T15:23:04.443Z",
    "updated_at": "2023-10-26T15:23:04.443Z",
    "created_by": "user:<USER_ID>",
    "updated_by": "user:<USER_ID>",
    "account": "<ACCOUNT_ID>",
    "allowed_projects": [
      "<PROJECT_ID>"
    ]
  }
]

Code Examples

List Environments

curl --location --request GET 'https://studio-server-production.api.becomposable.com/api/v1/environments' \
--header 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Create an Environment

Endpoint: /environments

Method: POST

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>

Input Parameters

ParameterData TypeDescription
namestringThe name of the environment
providerSupportedProvidersThe provider of the environment
descriptionstringAn optional description of the environment
endpoint_urlstringThe endpoint URL of the environment
default_modelstringThe default model for the environment
apiKeystringThe API key for the environment
configobjectThe configuration for the environment
allowed_projectsstring[]The projects that are allowed to use the environment

Example Request

{
  "name": "My OpenAI Environment",
  "provider": "openai",
  "description": "My OpenAI environment",
  "endpoint_url": "https://api.openai.com/v1",
  "default_model": "text-davinci-003",
  "apiKey": "sk-...",
  "config": {},
  "allowed_projects": [
    "<PROJECT_ID>"
  ]
}

Example Response

{
  "id": "<ENVIRONMENT_ID>",
  "name": "My OpenAI Environment",
  "provider": "openai",
  "description": "My OpenAI environment",
  "endpoint_url": "https://api.openai.com/v1",
  "default_model": "text-davinci-003",
  "apiKey": "sk-************************",
  "config": {},
  "account": "<ACCOUNT_ID>",
  "allowed_projects": [
    "<PROJECT_ID>"
  ],
  "created_by": "user:<USER_ID>",
  "updated_by": "user:<USER_ID>",
  "created_at": "2023-10-26T15:23:04.443Z",
  "updated_at": "2023-10-26T15:23:04.443Z"
}

Code Examples

Create an Environment

curl --location --request POST 'https://studio-server-production.api.becomposable.com/api/v1/environments' \
--header 'Authorization: Bearer <YOUR_JWT_TOKEN>' \
--header 'Content-Type: application/json' \
--data-raw '{
  "name": "My OpenAI Environment",
  "provider": "openai",
  "description": "My OpenAI environment",
  "endpoint_url": "https://api.openai.com/v1",
  "default_model": "text-davinci-003",
  "apiKey": "sk-...",
  "config": {},
  "allowed_projects": [
    "<PROJECT_ID>"
  ]
}'

Retrieve an Environment

Endpoint: /environments/<ENVIRONMENT_ID>

Method: GET

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>

Path Parameters

ParameterDescription
<ENVIRONMENT_ID>The ID of the environment to retrieve

Example Request

curl --location --request GET 'https://studio-server-production.api.becomposable.com/api/v1/environments/<ENVIRONMENT_ID>' \
--header 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Example Response

{
  "id": "<ENVIRONMENT_ID>",
  "name": "My OpenAI Environment",
  "provider": "openai",
  "description": "My OpenAI environment",
  "endpoint_url": "https://api.openai.com/v1",
  "default_model": "text-davinci-003",
  "apiKey": "sk-************************",
  "config": {},
  "account": "<ACCOUNT_ID>",
  "allowed_projects": [
    "<PROJECT_ID>"
  ],
  "created_by": "user:<USER_ID>",
  "updated_by": "user:<USER_ID>",
  "created_at": "2023-10-26T15:23:04.443Z",
  "updated_at": "2023-10-26T15:23:04.443Z"
}

Code Examples

Retrieve an Environment

curl --location --request GET 'https://studio-server-production.api.becomposable.com/api/v1/environments/<ENVIRONMENT_ID>' \
--header 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Update an Environment

Endpoint: /environments/<ENVIRONMENT_ID>

Method: PUT

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>

Path Parameters

ParameterDescription
<ENVIRONMENT_ID>The ID of the environment to update

Input Parameters

ParameterData TypeDescription
namestringThe name of the environment
providerSupportedProvidersThe provider of the environment
descriptionstringAn optional description of the environment
endpoint_urlstringThe endpoint URL of the environment
default_modelstringThe default model for the environment
apiKeystringThe API key for the environment
configobjectThe configuration for the environment
allowed_projectsstring[]The projects that are allowed to use the environment

Example Request

{
  "name": "My Updated OpenAI Environment",
  "description": "My updated OpenAI environment"
}

Example Response

{
  "id": "<ENVIRONMENT_ID>",
  "name": "My Updated OpenAI Environment",
  "provider": "openai",
  "description": "My updated OpenAI environment",
  "endpoint_url": "https://api.openai.com/v1",
  "default_model": "text-davinci-003",
  "apiKey": "sk-************************",
  "config": {},
  "account": "<ACCOUNT_ID>",
  "allowed_projects": [
    "<PROJECT_ID>"
  ],
  "created_by": "user:<USER_ID>",
  "updated_by": "user:<USER_ID>",
  "created_at": "2023-10-26T15:23:04.443Z",
  "updated_at": "2023-10-26T15:23:04.443Z"
}

Code Examples

Update an Environment

curl --location --request PUT 'https://studio-server-production.api.becomposable.com/api/v1/environments/<ENVIRONMENT_ID>' \
--header 'Authorization: Bearer <YOUR_JWT_TOKEN>' \
--header 'Content-Type: application/json' \
--data-raw '{
  "name": "My Updated OpenAI Environment",
  "description": "My updated OpenAI environment"
}'

Delete an Environment

Endpoint: /environments/<ENVIRONMENT_ID>

Method: DELETE

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>

Path Parameters

ParameterDescription
<ENVIRONMENT_ID>The ID of the environment to delete

Example Request

curl --location --request DELETE 'https://studio-server-production.api.becomposable.com/api/v1/environments/<ENVIRONMENT_ID>' \
--header 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Example Response

{
  "id": "<ENVIRONMENT_ID>"
}

Code Examples

Delete an Environment

curl --location --request DELETE 'https://studio-server-production.api.becomposable.com/api/v1/environments/<ENVIRONMENT_ID>' \
--header 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Get Available Models

Endpoint: /environments/<ENVIRONMENT_ID>/models

Method: GET

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>

Path Parameters

ParameterDescription
<ENVIRONMENT_ID>The ID of the environment

Query Parameters

ParameterData TypeDescription
textstringText to search for in the model name or description
typestringThe type of model to search for
tagsstringThe tags to search for in the model

Example Request

curl --location --request GET 'https://studio-server-production.api.becomposable.com/api/v1/environments/<ENVIRONMENT_ID>/models?text=davinci' \
--header 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Example Response

[
  {
    "id": "text-davinci-003",
    "object": "model",
    "created": 1678142652,
    "owned_by": "openai",
    "permission": [
      {
        "id": "modelperm-...",
        "object": "model_permission",
        "created": 1678142653,
        "allow_create_engine": false,
        "allow_sampling": true,
        "allow_logprobs": true,
        "allow_search_indices": false,
        "allow_view": true,
        "allow_fine_tuning": false,
        "organization": "*",
        "group": null,
        "is_blocking": false
      }
    ],
    "root": "text-davinci-003",
    "parent": null
  }
]

Code Examples

Get Available Models

curl --location --request GET 'https://studio-server-production.api.becomposable.com/api/v1/environments/<ENVIRONMENT_ID>/models' \
--header 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Generate Embeddings

Endpoint: /environments/<ENVIRONMENT_ID>/embeddings

Method: POST

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>

Path Parameters

ParameterDescription
<ENVIRONMENT_ID>The ID of the environment

Input Parameters

ParameterData TypeDescription
textstringThe text to generate embeddings for
imagestringThe image to generate embeddings for

Example Request

{
  "text": "This is a test"
}

Example Response

{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "embedding": [
        0.0123123,
        0.12312312,
        ...
      ],
      "index": 0
    }
  ],
  "model": "text-embedding-ada-002",
  "usage": {
    "prompt_tokens": 4,
    "total_tokens": 4
  }
}

Code Examples

Generate Embeddings

curl --location --request POST 'https://studio-server-production.api.becomposable.com/api/v1/environments/<ENVIRONMENT_ID>/embeddings' \
--header 'Authorization: Bearer <YOUR_JWT_TOKEN>' \
--header 'Content-Type: application/json' \
--data-raw '{
  "text": "This is a test"
}'

Was this page helpful?