No description
Find a file
2024-09-02 16:48:23 +01:00
examples make it usable, updating will come later 2024-08-17 23:32:00 +01:00
src [fix] unescaped strings and bump to 0.1.2, cant believe it took me this long to figure out what I was doing wrong 2024-09-02 16:48:23 +01:00
LICENSE.md Add MIT license 2023-05-15 04:23:35 +01:00
openaiClient.nimble [fix] unescaped strings and bump to 0.1.2, cant believe it took me this long to figure out what I was doing wrong 2024-09-02 16:48:23 +01:00
README.md make it usable, updating will come later 2024-08-17 23:32:00 +01:00
spec.yaml updated spec.yaml to version 1.3.0 2023-06-14 01:20:40 +01:00

OpenAI api client for Nim Lang

This is a simple implementation of a Nim lang client for the openai api spec (as found in the spec.yaml file above). This client has support for asynchronous requests and parameters are passed as json.

Installation

nimble install openaiclient

Usage

[1] Create a file to hold your apikeys and other environmental variables and construct a new openai client

import openaiClient

let
    env = loadEnv(".env")
    apiKey = env.get("API_KEY")
    openai = newOpenAiClient(apikey = apikey)
## if you need to use an asynchronous client then:
##import asyncdispatch
##let openai = newAsyncOpenAiClient(apikey = apikey)

[2] Setup your parameters as json and pass them to the openai functions you wish to call

import json

let imageEditRequestParams = %*{"image": "pic.png", "mask": "pic.png", "prompt": "A Nice Tesla For Asiwaju",   "n": 2, "size": "512x512"}

let imageEditResponse = openai.createImageEdit(imageEditRequestParams)

#use the response for whatever cool stuff you are trying to do

echo imageEditResponse

Contributions

Contributions to the OpenAI Nim client are welcome. If you find a bug or have a suggestion for a new feature, please open an issue on the GitHub repository. If you would like to contribute code, please fork the repository and submit a pull request.