DEV Community

0xkoji
0xkoji

Posted on

How to Use OpenAI Fine-tuning API with JavaScript

steps

[requirements]

  • OpenAI API Key
  • Node v16
  • npm/yarn/pnpm
  • python3 (3.7+)
  1. prepare dataset for the API
  2. upload a file
  3. return the file id
  4. send train request
  5. return model id

Details are in my repo.

GitHub logo koji / open-ai-fine-tuning-script

js scripts for OpenAI fine tuning API

Fine Tuning API with javascript

https://platform.openai.com/docs/guides/fine-tuning

fine tuning api steps

steps

  1. prepare dataset for the API
  2. upload a file
  3. return the file id
  4. send train request
  5. return model id

Before running the script

Before running the node script, we need to do a couple of things.
requirements python + nodejs

  1. Get OpenAI API Key Go to the following url and create a new API key.
    https://platform.openai.com/account/api-keys
    Then you need to create .env file from .env.sample and put the API key you got.

  2. Prepare the dataset For using OpenAI fine-tuning API, we will need to upload the dataset so first we need to create a file which is a jsonl.
    The format is below sample: data.jsonl

{ "prompt": "users' question", "completion": "answer to the question" }
// sample
{ "prompt": "What is the OT-2 Python Protocol API? ", "completion": "The OT-2 Python
…
Enter fullscreen mode Exit fullscreen mode

Top comments (0)