OpenAI Proxy
Integrate via Langtail SDK
If you want to give Langtail a try but you’re not 100% sure that you want to use the full Langtail workflow, using the using the OpenAI Proxy via the SDK is a great way to get started. Follow these steps to get up and running:
1
Generate a project API key
- In Langtail, open an existing project or create a new one.
- In the left sidebar, click Secrets.
- Click New API Key, optionally set a name and a budget limit, then click Create.
- Copy the key.
2
Install the SDK
Install the Langtail SDK in your project (using NPM or your package manager of choice):
3
Modify your code to use the SDK
- Add your Langtail project API key to an environment variable. In the following snippets, we use
LANGTAIL_API_KEY
. - In your codebase, paste this snippet:
4
Test it out
Run your app and make a request to verify that everything works properly.
5
Observe metrics and logs
- Back in Langtail, navigate to the project and then click Logs in the left sidebar.
- You should see log entries coming from your app (they have an environment value of “proxy”).
- Click on a log to see detailed information about the request and response from OpenAI.
- If you want to experiment with this prompt, click Open in Playground. Here you can change parameters and modify different parts of the prompt and then see the result.