Search packages, repositories and app categories

Package detailsv0.0.7

openai_client

An unofficial, platform independent, client for accessing different AI models developed by OpenAI.

AndroidiOSmacOSWindowsLinux
30-day downloads
101
Likes
49
Pub points
140

Install package

flutter pub add openai_client

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The openai_client package is an unofficial, platform-independent Dart client for interacting with OpenAI's AI models. It enables developers to integrate generative AI capabilities—such as text generation and chat responses—into Flutter applications across Android, iOS, macOS, Windows, and Linux. Designed for simplicity and flexibility, it supports various OpenAI endpoints without requiring platform-specific code. The client abstracts HTTP interactions, making it easy to authenticate and send requests using API keys. Ideal for building AI-powered features in cross-platform apps.

Use cases

  • Integrating chatbots into mobile and desktop apps
  • Generating content using GPT models
  • Building AI assistants with natural language processing
  • Enabling real-time text completion
  • Creating multilingual translation tools

Key features

  • Cross-platform compatibility
  • Simple API for OpenAI endpoints
  • Support for authentication via API key
  • Asynchronous request handling
  • Lightweight and easy to integrate

Suitable for

  • Flutter developers building AI-powered apps
  • Teams needing multi-platform AI integration
  • Projects requiring generative text capabilities
  • Prototyping AI features quickly
  • Apps targeting both mobile and desktop users

Considerations

  • Unofficial client—may require updates after OpenAI API changes
  • Requires proper management of API keys
  • Dependent on stable internet connection
  • Limited to OpenAI's available models
  • Not suitable for high-frequency or mission-critical AI workloads

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

alt Banner of the openai_client project

The OpenAI API can be applied to virtually any task that involves understanding or generating natural language or code. They offer a spectrum of models with different levels of power suitable for different tasks, as well as the ability to fine-tune your own custom models.

ℹ️ Info

This is an unofficial client, written purely in Dart that allows you to easily use the API in your Dart or Flutter projects.

APIs Dart class Implementation status
Models OpenAIModels ✅
Completions OpenAICompletions ✅
Chat OpenAIChat ✅
Edits OpenAIEdits ✅
Images OpenAIImages ✅
Embeddings OpenAIEmbeddings ✅
Files Not present ❌
Fine-tunes Not present ❌
Moderations OpenAIModerations ✅

🧰 Installation

You can install the package by adding it to your pubspec.yaml file.

dependencies:
  openai_client: last_version

After the installation you would just need to import the package in your project.

import 'package:openai_client/openai_client.dart';

🚀 Getting Started

In order to use the API, you need to have an API key. You can get one here and once you have it, you can use it in the client passing the key itself in the OpenAIConfiguration constructor.

// Create the configuration
final conf = OpenAIConfiguration(
    apiKey: 'Your API key',
    organizationId: 'Your organization ID', // Optional
);

// Create a new client
final client = OpenAIClient(configuration: conf);

🐛 Debugging

For testing and debugging purposes, you can use the built-in Logger to more easily check the status of requests and responses.

By default, the Logger is disabled. You can enable it by setting the enableLogging property to true.

// The instance of the client with the logger enabled
final client = OpenAIClient(
    ...
    enableLogging: true,
);

🎯 Examples

The provided example is a simple command line application that allows you to test the client. You can find it in the example folder.

📚 Documentation

The full documentation of the project is available here. All the methods are documented, and you can easily check the parameters that you can pass to them.

🤝 Contributing

If you want to contribute to openai_client, please make sure to review the contribution guidelines.

This project makes use of GitHub issues for tracking requests and bugs only, so please don't use issues for general questions and discussion.

🪪 License

This project is licensed under the BSD-3-Clause.

Furthermore, it's not affiliated with OpenAI in any way.

Categories

Dependencies

Dependency list 3 items

Source repository

Projects using this package

No data available yet.