OpenAI API Client

For your PHP and JavaScript applications, that uses fully typed requests and responses.

Add Artificial Intelligence to your PHP or JavaScript applications in minutes.

Supports popular OpenAI features and models including ChatGPT, GPT-4, GPT-3.5, GPT-3, Codex, DALL·E and Whisper.

Easily connect up to the popular Chat Completions, Completions, Images, Audio Transcriptions, Fine-Tuning, Moderations and Embeddings endpoints using smart data objects that have full knowledge of the data type and structures so you can quickly and easily implement your user application.

Integrating OpenAI into your JavaScript application is now as simple as:

const tectalicOpenai = require('@tectalic/openai').default;
 
const openaiClient = tectalicOpenai(process.env.OPENAI_API_KEY);
 
const response = openaiClient.completions.create({
model: 'text-davinci-003',
prompt: 'Will using a third party package save time?'
})
 
response.then((result) => {
console.log(result.data.choices[0].text)
});
// Using a third party package can save time because you don't have to write the code yourself.

Integrating OpenAI into your PHP application is now as simple as:

$openaiClient = \Tectalic\OpenAi\Manager::build(
new \GuzzleHttp\Client(),
new \Tectalic\OpenAi\Authentication(getenv('OPENAI_API_KEY'))
);
 
/** @var \Tectalic\OpenAi\Models\ChatCompletions\CreateResponse $response */
$response = $openaiClient->chatCompletions()->create(
new \Tectalic\OpenAi\Models\ChatCompletions\CreateRequest([
'model' => 'gpt-4',
'messages' => [
[
'role' => 'user',
'content' => 'Will using a well designed and supported third party package save time?',
],
],
])
)->toModel();
 
echo $response->choices[0]->message->content;
// Yes, using a well-designed and supported third-party package can save time during software development.

You can even train your own unique AI model using Fine Tunes to ensure your app stands out from the crowd.

See the PHP Examples and JavaScript examples for full details.

OpenAI Logo

OpenAI API Client Features

Fully Typed Smart Data Objects

All requests and responses are fully typed, with complete details of the OpenAI API request and response structures at your fingertips.

IDE Autocompletion

All API endpoints, requests and responses are fully documented within advanced IDEs such as Visual Studio Code or PhpStorm.

Faster API Integration Projects

Spend your time building great software, not reading complex API documentation.

All 23 Endpoints Supported

Make full use of the OpenAI API, with the ability to easily query all 23 API endpoints.

Fully Tested

By our developers, with unit and functional integration tests. All test cases are provided.

Fully Supported

Our Australian-based team of developers are here to help you.

Imagine...
a OpenAI JavaScript API Client

Written in JavaScript

With everything you need

  • A convenient interface for interacting with the OpenAI API.
  • Type definitions for all requests and responses.
  • Supports Node.js, JavaScript or Typescript applications.
  • Simple installation via npm.

Imagine...
a OpenAI PHP API Client

Written in PHP

With everything you need

  • A convenient fluent interface for interacting with the OpenAI API.
  • Data Transfer Objects (DTOs) for all requests and responses.
  • Compatible with PHP versions 7.2.5 → 8.1.

From the Blog

Announcement

A GPT-4 and GPT-3.5 ChatGPT API Client for Your PHP Applications

The Tectalic OpenAI PHP Client Library now supports the new ChatGPT and Whisper APIs, including GPT-4 and GPT-3.5.

Read more
Announcement

An OpenAI API Client (SDK) for Your JavaScript Projects

Our new OpenAI REST API Client is now available, with GPT-3, Codex and DALL·E model support. Includes Typescript declarations for all requests and responses and IDE autocomplete support.

Read more
Tutorial

How to build a PHP app using the OpenAI API

Learn how to build an AI-based business name generator application using PHP, Laravel and the OpenAI API.

Read more
Announcement

An OpenAI API Client (SDK) for Your PHP Projects

Our new OpenAI REST API Client is now available, with GPT-3 and Codex model support. Includes Data Transfer Objects (DTOs) for all requests and responses and IDE autocomplete support.

Read more