Popularity
57 Stars
Updated Last
1 Year Ago
Started In
April 2022

OpenAI API wrapper for Julia (Unofficial)

Overview

Provides a community maintained Julia wrapper to the OpenAI API. For API functionality see reference documentation. Autogenerated documentation can be found here: https://juliaml.github.io/OpenAI.jl/dev/

Usage

using Pkg; Pkg.add("OpenAI")

Quick Start

  1. Create an OpenAI account, if you don't already have one

  2. Create a secret API key

  3. Choose a model to interact with

⚠️ We strongly suggest setting up your API key as an ENV variable.

secret_key = "PAST_YOUR_SECRETE_KEY_HERE"
model = "gpt-3.5-turbo"
prompt =  "Say \"this is a test\""

r = create_chat(
    secret_key, 
    model,
    [Dict("role" => "user", "content"=> prompt)]
  )
println(r.response[:choices][begin][:message][:content])

returns

"This is a test."

For more use cases see tests.

Feature requests

Feel free to open a PR, or file an issue if that's out of reach!

Used By Packages