Reference

Completions

You can get privacy-conserving text completions from any of the available models using a call to the /completions REST API endpoint or the Completion class in the Python client.

Generate a text completion

To generate a text completion, you can use the following code examples. Depending on your preference or requirements, select the appropriate method for your application.

1import os
2import json
3
4import predictionguard as pg
5
6# Set your Prediction Guard token as an environmental variable.
7os.environ["PREDICTIONGUARD_TOKEN"] = "<your access token>"
8
9response = pg.Completion.create(
10 model="Nous-Hermes-Llama2-13B",
11 prompt="The best joke I know is: "
12)
13
14print(json.dumps(
15 response,
16 sort_keys=True,
17 indent=4,
18 separators=(',', ': ')
19))

This approach presents a straightforward way for readers to choose and apply the code example that best suits their needs for generating text completions using either Python or cURL.