Do you love C programming but feel left out from the AI boom?
Say hello to openai-c
— a lightweight, dependency-minimal, MIT-licensed C client for the OpenAI Chat API.
✨ What is OpenAI C
?
openai-c
is a minimal wrapper around OpenAI’s Chat Completion API, written in pure C11. It lets you send prompts to models like gpt-3.5-turbo
and get back responses — all without leaving your beloved C codebase.
🚀 Features
- Written entirely in C (C11 standard)
- Supports
gpt-3.5-turbo
and customizable model names - Simple API:
openai_init()
,openai_chat()
,openai_cleanup()
- Uses
libcurl
andcJSON
- Lightweight and fast
- MIT licensed
🧩 Basic Usage
#include <stdio.h>
#include "openai.h"
int main() {
openai_init("your-api-key");
char* res = openai_chat("Hello, who are you?");
if (res) {
printf("OpenAI says: %s\n", res);
free(res);
}
openai_cleanup();
return 0;
}
📦 Installation
git clone https://github.com/LunaStev/openai-c.git
cd openai-c
mkdir build && cd build
cmake ..
make
sudo make install
📂 Folder Structure
openai-c/
├── include/ # openai.h
├── src/ # openai.c
├── examples/ # usage examples
├── CMakeLists.txt
└── LICENSE # MIT License
🔧 Dependencies
📜 License
MIT License – free to use, modify, and distribute.
🌎 GitHub
👉 Check it out: https://github.com/LunaStev/openai-c