Reference·PHP SDK · BIMworksPHP

AIApi

PHP SDK: the AI - Artificial Intelligence operations, 1 method, each with its parameters, result and a complete example.

PHP SDK · BIMworks\Api · class · 1 method

Natural-language calls, for example to turn a sentence into a BQL query, a BVL visualisation or a BCL check

Construct it with the client of the connect step: new AIApi(config: $client). Each method is one operation of the API part, where it runs on its page.

MethodOperationDescription
textToActionTextToActionTurn a sentence into a BIM.works action (BQL, BVL or BCL)

textToAction#

PHP#
public function textToAction(TextToActionRequest $text_to_action_request): TextToActionResult

Turn a sentence into a BIM.works action (BQL, BVL or BCL). Sends the text to the language model the instance is configured with (the account's default text-to-action model, else the server's ai.default_text_to_action) and returns the action it wrote: a BQL query, a BVL visualisation or a BCL check. The server parses and formats the code before it answers; code that does not parse goes back to the model once with the parser's error, and fails with 502 when the second answer does not parse either.

OperationTextToAction · POST /openapi/ai/TextToAction
Scopeai:use

Parameters#

NameTypeDescription
text_to_action_requestTextToActionRequestrequiredThe request: its properties are those of the model, its JSON that of TextToAction's request body.

Returns#

TextToActionResult — The action

Example#

PHP#
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AIApi;
use BIMworks\Api\AuthApi;
use BIMworks\Configuration;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\Model\TextToActionRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('https://bim.works/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => "<your API token>"]));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "input": "Show the external walls in red",
  "models": [
    {
      "type": "VersionModelIdentifier",
      "uuid": "<version uuid of the first demo model>"
    }
  ]
}
JSON, TextToActionRequest::class);

// 3. The call
$result = (new AIApi(config: $client))->textToAction($request);

// 4. The result
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), PHP_EOL;