Handle Skills ?

Hello,

Does it exists a way, with OpenAI/ChatGPT for example, to handle skill like described here :

You can upload skill like that :

function UploadSkill(
  const APIKey, ASkillZIPFile: string): string;
var
  Client: THTTPClient;
  FormData: TMultipartFormData;
  Response: IHTTPResponse;
  ResponseText: string;
  JSON: TJSONValue;
  IDValue: TJSONValue;
begin
  Result := '';

  if Trim(APIKey) = '' then
    raise Exception.Create(' API OpenAI key is empty.');

  if not FileExists(ASkillZIPFile) then
    raise Exception.CreateFmt(
      'ZIP file not found : %s', [ASkillZIPFile]);

  Client := THTTPClient.Create;
  try
    Client.ConnectionTimeout := 30000;
    Client.ResponseTimeout := 300000;

    FormData := TMultipartFormData.Create;
    try
      FormData.AddFile(
        'files',
        ASkillZIPFile,
        'application/zip'
      );


      Response := Client.Post(
        'https://api.openai.com/v1/skills',
        FormData,
        nil,
        [
          TNameValuePair.Create(
            'Authorization', 'Bearer ' + APIKey)
        ]
      );

      ResponseText :=
        Response.ContentAsString(TEncoding.UTF8);

      if (Response.StatusCode < 200) or
         (Response.StatusCode >= 300) then
        raise Exception.CreateFmt(
          'Error upload OpenAI HTTP %d : %s',
          [Response.StatusCode, ResponseText]
        );

      JSON := TJSONObject.ParseJSONValue(ResponseText);
      try
        if not (JSON is TJSONObject) then
          raise Exception.Create(
            'Réponse JSON OpenAI invalide : ' + ResponseText);

        IDValue := TJSONObject(JSON).GetValue('id');

        if not (IDValue is TJSONString) then
          raise Exception.Create(
            'Skill ID not exists : ' + ResponseText);

        Result := IDValue.Value;

        if Result = '' then
          raise Exception.Create(
            'Skill Id is empty.');
      finally
        JSON.Free;
      end;
    finally
      FormData.Free;
    end;
  finally
    Client.Free;
  end;
end;

And use it like that :

function CallSkill(
  const APIKey, SkillID, Prompt: string): string;
var
  Client: THTTPClient;
  Body: TStringStream;
  Response: IHTTPResponse;
  Payload: string;
begin
  Payload :=
    '{' +
      '"model":"gpt-6-astra",' +
      '"tools":[{' +
        '"type":"shell",' +
        '"environment":{' +
          '"type":"container_auto",' +
          '"skills":[{' +
            '"type":"skill_reference",' +
            '"skill_id":' + JSONString(SkillID) +
          '}]' +
        '}' +
      '}],' +
      '"input":' + JSONString(Prompt) +
    '}';

  Client := THTTPClient.Create;
  try
    Client.ConnectionTimeout := 30000;
    Client.ResponseTimeout := 300000;

    Body := TStringStream.Create(Payload, TEncoding.UTF8);
    try
      Response := Client.Post(
        'https://api.openai.com/v1/responses',
        Body,
        nil,
        [
          TNameValuePair.Create(
            'Authorization', 'Bearer ' + APIKey),
          TNameValuePair.Create(
            'Content-Type', 'application/json')
        ]
      );

      Result := Response.ContentAsString(TEncoding.UTF8);

      if (Response.StatusCode < 200) or
         (Response.StatusCode >= 300) then
        raise Exception.CreateFmt(
          'Error OpenAI HTTP %d : %s',
          [Response.StatusCode, Result]
        );
    finally
      Body.Free;
    end;
  finally
    Client.Free;
  end;
end;

Skills are very powerfull !

Best regards

That is indeed on our todolist.
We are checking the cross service feasibility of this particular feature to see how we can proceed.