Getting Started with the GooseAI API
The GooseAI platform was built to be easily interchangeable with industry standard APIs, including the OpenAI API Client.
To get started using GooseAI from the OpenAI API Client, follow the instructions below for your preferred environment or language:
Shell
curl https://api.goose.ai/v1/engines/gpt-j-6b/completions \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer sk-******' \
-d '{
"prompt": "Roses are red ",
"max_tokens": 25
}'
Python
To access the GooseAI API from the Python OpenAI API Client, install via pip:
$ pip install openai
Once the OpenAI Client is available for your environment, you can test it out with the following:
import openai
openai.api_key = "sk-..."
openai.api_base = "https://api.goose.ai/v1"
# List Engines (Models)
engines = openai.Engine.list()
# Print all engines IDs
for engine in engines.data:
print(engine.id)
# Create a completion, return results streaming as they are generated. Run with `python3 -u` to ensure unbuffered output.
completion = openai.Completion.create(
engine="gpt-j-6b",
prompt="Once upon a time there was a Goose. ",
max_tokens=160,
stream=True)
# Print each token as it is returned
for c in completion:
print (c.choices[0].text, end = '')
print("")
NodeJS
To access the GooseAI API from the NodeJS OpenAI API Client, install via npm:
$ npm install openai
Once the OpenAI Client is available for your environment, you can test it out with the following:
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: 'sk-...',
basePath: 'https://api.goose.ai/v1',
});
const openai = new OpenAIApi(configuration);
openai.createCompletion("gpt-j-6b", {
prompt: `Roses are red `,
max_tokens: 25,
}).then(
completion =>
console.log(completion.data.choices[0].text)
);