Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Commit

Permalink
added OpenAI NodeJS example to the docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Lenton committed Jul 24, 2024
1 parent 7139656 commit a7e7547
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions docs/concepts/unify_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ There are three ways to query the API:
- OpenAI Python package


HTTP request
HTTP Request
^^^^^^^^^^^^
Run the following command in a terminal (replacing :code:`$UNIFY_API_KEY` with your own).

Expand Down Expand Up @@ -106,7 +106,7 @@ Sample inference
unify = Unify("llama-3-8b-chat@fireworks-ai", api_key="$UNIFY_API_KEY")
response = unify.generate("Say hi.")
OpenAI Python package
OpenAI Python Package
^^^^^^^^^^^^^^^^^^^^^
The Unify API is designed to be compatible with the OpenAI standard, so if you have existing code that uses the OpenAI Python package, it's straightforward to try out our API.

Expand All @@ -129,6 +129,25 @@ The Unify API is designed to be compatible with the OpenAI standard, so if you h
Remember that the :code:`model` field needs to contain a string of the form :code:`model@provider`.

OpenAI NodeJS Package
^^^^^^^^^^^^^^^^^^^^^
Likewise, if you have existing code that uses the OpenAI NodeJS package, it's straightforward to try out our API.

.. code-block:: javascript
const openai = new OpenAI({
baseUrl: "https://api.unify.ai/v0/",
apiKey: "YOUR_UNIFY_KEY"
});
const stream = await openai.chat.completions.create({
model: "mistral-7b-instruct-v0.3@fireworks-ai",
messages: [{"role": "user", "content": "Say hi."}],
stream: true
});
Again, remember that the :code:`model` field needs to contain a string of the form :code:`model@provider`.

Billing
-------
You only have to manage the balance and billing details for your Unify account, and we handle the spending with each provider behind the scenes.
Expand Down

0 comments on commit a7e7547

Please sign in to comment.