### Install OpenAI Python Client Source: https://goose.ai/docs/api Install the required package via pip to enable GooseAI API access in Python. ```bash $ pip install openai ``` -------------------------------- ### Install OpenAI NodeJS Client Source: https://goose.ai/docs/api Install the required package via npm to enable GooseAI API access in NodeJS. ```bash $ npm install openai ``` -------------------------------- ### Configure stop sequences Source: https://goose.ai/docs/api/completions Examples of defining stop sequences as a single string or an array of strings. ```json {... "stop": " goose", ...} ``` ```json {... "stop: [" geese", " gooose", "<|endoftext|>"], ...} ``` -------------------------------- ### Configure logit_bias for gpt-neo-20b Source: https://goose.ai/docs/api/completions Example of applying logit bias to specific token IDs for the gpt-neo-20b model. ```json {... "logit_bias": {"0": -100, "187": 0.5}, ...} ``` -------------------------------- ### Get Engine Details Source: https://goose.ai/docs/api/engines Retrieves information about a specific engine available in the API, such as its owner, name, availability, and a brief description. ```APIDOC ## GET /v1/engines/{engine_id} ### Description Gets information about an individual engine available, such as the owner, name, availability, and description. ### Method GET ### Endpoint /v1/engines/{engine_id} ### Parameters #### Path Parameters - **engine_id** (string) - Required - The unique identifier of the engine. ### Request Example ```curl curl https://api.goose.ai/v1/engines/gpt-j-6b \ -H 'Authorization: Bearer YOUR_API_KEY' ``` ### Response #### Success Response (200) - **description** (string) - A description of the engine. - **id** (string) - The unique identifier of the engine. - **name** (string) - The display name of the engine. - **object** (string) - The type of object, expected to be "engine". - **owner** (string) - The owner of the engine. - **ready** (boolean) - Indicates if the engine is ready for use. - **tokenizer** (string) - The tokenizer used by the engine. - **type** (string) - The type of the engine (e.g., "text"). #### Response Example ```json { "description": "6B parameter EleutherAI model trained on the Pile, using the Mesh Transformer JAX framework.", "id": "gpt-j-6b", "name": "GPT-J 6B", "object": "engine", "owner": "gooseai", "ready": true, "tokenizer": "gpt2", "type": "text" } ``` ``` -------------------------------- ### Configure logit_bias for other models Source: https://goose.ai/docs/api/completions Example of applying logit bias to specific token IDs for models other than gpt-neo-20b. ```json {... "logit_bias": {"50256": -100, "198": 0.5}, ...} ``` -------------------------------- ### Get Specific Engine Information Source: https://goose.ai/docs/api/engines Retrieve details about a single engine by its ID. Ensure you replace `{engine_id}` with the actual engine identifier. ```HTTP GET https://api.goose.ai/v1/engines/{engine_id} ``` ```curl curl https://api.goose.ai/v1/engines/gpt-j-6b \ -H 'Authorization: Bearer YOUR_API_KEY' ``` ```json { "description": "6B parameter EleutherAI model trained on the Pile, using the Mesh Transformer JAX framework.", "id": "gpt-j-6b", "name": "GPT-J 6B", "object": "engine", "owner": "gooseai", "ready": true, "tokenizer": "gpt2", "type": "text" } ``` -------------------------------- ### POST /v1/engines/{engine_id}/completions Source: https://goose.ai/docs/api/completions Creates a new completion for the provided prompt and parameters. ```APIDOC ## POST /v1/engines/{engine_id}/completions ### Description Creates a new completion for the provided prompt and parameters. ### Method POST ### Endpoint /v1/engines/{engine_id}/completions ### Parameters #### Path Parameters - **engine_id** (string) - Required - The ID of the engine to use for this request. ``` -------------------------------- ### Interact with GooseAI API in Python Source: https://goose.ai/docs/api Configure the OpenAI client to point to the GooseAI base URL and perform engine listing and completion tasks. ```python 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("") ``` -------------------------------- ### List All Available Engines Source: https://goose.ai/docs/api/engines Fetch a list of all engines currently available through the API, including their descriptions and configurations. This endpoint provides an overview of the models you can utilize. ```HTTP GET https://api.goose.ai/v1/engines ``` ```curl curl https://api.goose.ai/v1/engines \ -H 'Authorization: Bearer YOUR_API_KEY' ``` ```json { "data": [ { "description": "20B parameter EleutherAI model trained on the Pile, using the NeoX framework.", "id": "gpt-neo-20b", "name": "GPT-NeoX 20B", "object": "engine", "owner": "gooseai", "ready": true, "tokenizer": "pile", "type": "text" }, { "description": "6B parameter EleutherAI model trained on the Pile, using the Mesh Transformer JAX framework.", "id": "gpt-j-6b", "name": "GPT-J 6B", "object": "engine", "owner": "gooseai", "ready": true, "tokenizer": "gpt2", "type": "text" }, { "description": "2.7B parameter EleutherAI model trained on the Pile, using the Neo framework.", "id": "gpt-neo-2-7b", "name": "GPT-Neo 2.7B", "object": "engine", "owner": "gooseai", "ready": true, "tokenizer": "gpt2", "type": "text" }, { "description": "1.3B parameter EleutherAI model trained on the Pile, using the Neo framework.", "id": "gpt-neo-1-3b", "name": "GPT-Neo 1.3B", "object": "engine", "owner": "gooseai", "ready": true, "tokenizer": "gpt2", "type": "text" }, { "description": "125M parameter EleutherAI model trained on the Pile, using the Neo framework.", "id": "gpt-neo-125m", "name": "GPT-Neo 125M", "object": "engine", "owner": "gooseai", "ready": true, "tokenizer": "gpt2", "type": "text" }, { "description": "13B parameter Facebook Mixture of Experts model trained on RoBERTa and CC100 subset data.", "id": "fairseq-13b", "name": "Fairseq 13B", "object": "engine", "owner": "gooseai", "ready": true, "tokenizer": "gpt2", "type": "text" }, { "description": "6.7B parameter Facebook Mixture of Experts model trained on RoBERTa and CC100 subset data.", "id": "fairseq-6-7b", "name": "Fairseq 6.7B", "object": "engine", "owner": "gooseai", "ready": true, "tokenizer": "gpt2", "type": "text" }, { "description": "2.7B parameter Facebook Mixture of Experts model trained on RoBERTa and CC100 subset data.", "id": "fairseq-2-7b", "name": "Fairseq 2.7B", "object": "engine", "owner": "gooseai", "ready": true, "tokenizer": "gpt2", "type": "text" }, { "description": "1.3B parameter Facebook Mixture of Experts model trained on RoBERTa and CC100 subset data.", "id": "fairseq-1-3b", "name": "Fairseq 1.3B", "object": "engine", "owner": "gooseai", "ready": true, "tokenizer": "gpt2", "type": "text" }, { "description": "125M parameter Facebook Mixture of Experts model trained on RoBERTa and CC100 subset data.", "id": "fairseq-125m", "name": "Fairseq 125M", "object": "engine", "owner": "gooseai", "ready": true, "tokenizer": "gpt2", "type": "text" } ], "object": "list" } ``` -------------------------------- ### List All Engines Source: https://goose.ai/docs/api/engines Lists all currently available engines and provides basic information about each, including owner and availability. ```APIDOC ## GET /v1/engines ### Description Lists the currently available engines, and provides basic information about each one such as the owner and availability. ### Method GET ### Endpoint /v1/engines ### Request Example ```curl curl https://api.goose.ai/v1/engines \ -H 'Authorization: Bearer YOUR_API_KEY' ``` ### Response #### Success Response (200) - **data** (array) - A list of engine objects. - Each object contains: - **description** (string) - A description of the engine. - **id** (string) - The unique identifier of the engine. - **name** (string) - The display name of the engine. - **object** (string) - The type of object, expected to be "engine". - **owner** (string) - The owner of the engine. - **ready** (boolean) - Indicates if the engine is ready for use. - **tokenizer** (string) - The tokenizer used by the engine. - **type** (string) - The type of the engine (e.g., "text"). - **object** (string) - The type of object, expected to be "list". #### Response Example ```json { "data": [ { "description": "20B parameter EleutherAI model trained on the Pile, using the NeoX framework.", "id": "gpt-neo-20b", "name": "GPT-NeoX 20B", "object": "engine", "owner": "gooseai", "ready": true, "tokenizer": "pile", "type": "text" }, { "description": "6B parameter EleutherAI model trained on the Pile, using the Mesh Transformer JAX framework.", "id": "gpt-j-6b", "name": "GPT-J 6B", "object": "engine", "owner": "gooseai", "ready": true, "tokenizer": "gpt2", "type": "text" } ], "object": "list" } ``` ``` -------------------------------- ### Interact with GooseAI API in NodeJS Source: https://goose.ai/docs/api Configure the OpenAI client with the GooseAI base path and execute a completion request. ```javascript 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) ); ``` -------------------------------- ### Text Completion API Source: https://goose.ai/docs/api/completions This endpoint generates text completions based on provided prompts and various configuration parameters. ```APIDOC ## POST /websites/goose_ai ### Description Generates text completions for one or more prompts. ### Method POST ### Endpoint /websites/goose_ai ### Parameters #### Request Body - **prompt** (string or array) - Optional - Defaults to <|endoftext|> - The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays. If multiple prompts are provided in a single request, they will be acted upon concurrently. - **n** (integer) - Optional - Defaults to 1 - The number of completions to perform per prompt. If more than 1 completion is requested, they will be fulfilled concurrently. - **max_tokens** (integer) - Optional - Defaults to 16 - The maximum number of tokens to generate in the completion. The token count of your prompt plus max_tokens cannot exceed the model's context length. - **min_tokens** (integer) - Optional - Defaults to 1 - The minimum number of tokens to generate in the completion. If stop tokens are seen before min_tokens, these tokens will be allowed to be generated. - **temperature** (number) - Optional - Defaults to 1.0 - Number between 0 and 1.0. What sampling temperature to use. Higher values mean the model will take more risks. - **top_p** (number) - Optional - Defaults to 1.0 - Number between 0 and 1.0. An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. - **logit_bias** (map) - Optional - Defaults to null - Bias for or against the specified tokens appearing. Keys are token IDs and values are floating points ranging from -100 to 100. - **stop** (string or array) - Optional - Defaults to null - Stops completion when a string or one of the strings in the array is encountered. - **top_k** (integer) - Optional - Defaults to 0 - Truncates logits to the set value. - **tfs** (number) - Optional - Defaults to 1.0 - Number between 0 and 1.0. Similar to nucleus sampling, but it sets its cutoff point based on the cumulative sum of the accelerations of the sorted token probabilities. - **top_a** (number) - Optional - Defaults to 1.0 - Number between 0 and 1.0. Remove all tokens that have probability below the threshold of: limit = pow(max(probs), 2.0) * top_a. - **typical_p** (number) - Optional - Defaults to 1.0 - Number between 0 and 1.0. Selects tokens according to the expected amount of information they contribute. - **stream** (boolean) - Optional - Defaults to false - Whether to stream back partial progress. - **logprobs** (integer) - Optional - Defaults to null - Include the log probabilities on the logprobs most likely tokens, as well as the chosen tokens. - **echo** (boolean) - Optional - Defaults to false - Echo back the prompt in addition to the completion. ### Request Example ```json { "prompt": "The quick brown fox", "max_tokens": 50, "temperature": 0.7 } ``` ### Response #### Success Response (200) - **choices** (array) - An array of completion choices. - **created** (integer) - Timestamp of creation. - **id** (string) - Unique identifier for the completion. - **model** (string) - The model used for completion. - **object** (string) - The type of object returned. - **usage** (object) - Usage statistics for the completion. #### Response Example ```json { "choices": [ { "finish_reason": "stop", "index": 0, "logprobs": null, "text": " jumps over the lazy dog." } ], "created": 1506817577, "id": "cmpl-7q8k3", "model": "gpt-3.5-turbo-instruct", "object": "text_completion", "usage": { "completion_tokens": 5, "prompt_tokens": 4, "total_tokens": 9 } } ``` ``` -------------------------------- ### Execute API Request via Shell Source: https://goose.ai/docs/api Use curl to send a completion request directly to the GooseAI API endpoint. ```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 }' ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.