Skip to content

Use the Formulaic API to easily manage prompts

The Formulaic API enables you to dynamically use Formulas in code. In order to access the API, you must create an API Key on your Formulaic Profile

[!IMPORTANT]
Never publically share or commit your API Key. The key enables access to your Formulaic account.

Endpoints

Formulas

Formulas provide metadata surrounding a sequence of prompts (not the prompts themselves).

GET a specific formula by ID

https://formulaic.app/api/recipes/<id>

Curl example request

curl 'https://formulaic.app/api/recipes/dec0983b-9c82-4107-b53c-fc5b481704ff' \
 -H 'Accept: */*' -H 'Content-Type: application/json' \
 -H "Authorization: Bearer <REPLACE_WITH_KEY>"

Example 200 Response

{
  "id": "899e2cbb-2887-4646-8e83-b2d319b52441",
  "username": "myusername",
  "name": "My formula Name",
  "description": "The description of a formula",
  "created_at": "2024-04-03T13:26:00.012Z",
  "updated_at": "2024-04-03T13:26:00.012Z",
  "image": null,
  "status": "published",
  "isFavorite": false
}

Scripts

Every Formula has a script. A script contains all the information needed to run inference against the prompts including model, variables and the sequence of prompts.

GET a specific script by Formula ID

https://formulaic.app/api/recipes/<id>/scripts

Curl example request

curl 'https://formulaic.app/api/recipes/dec0983b-9c82-4107-b53c-fc5b481704ff/scripts' \
 -H 'Accept: */*' -H 'Content-Type: application/json' \
 -H "Authorization: Bearer <REPLACE_WITH_KEY>"

Example Response

{
  "id": "bdfe8ab7-44b5-42fa-aeea-1e5c1bf07523",
  "recipe_id": "dec0983b-9c82-4107-b53c-fc5b481704ff",
  "created_at": "2024-04-03T13:26:00.018Z",
  "updated_at": "2024-04-10T14:12:01.457Z",
  "script": {
    "model": {
      "id": "mistralai/Mistral-7B-Instruct-v0.1",
      "name": "Mistral 7B Instruct",
      "vendor": "Mistral",
      "provider": "Anyscale"
    },
    "sequences": [
      [
        {
          "text": "Tell me more about the following: {{{name}}}"
        },
        {
          "text": "Summarize the explaination into two words."
        }
      ]
    ],
    "variables": [
      {
        "name": "name",
        "type": "text",
        "value": "elephants"
      }
    ]
  }
}