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

Commit

Permalink
Deploying to main from @ unifyai/unify-docs@c397f83 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
ivy-seed committed Jul 30, 2024
1 parent 7ed5016 commit f0684f6
Show file tree
Hide file tree
Showing 14 changed files with 155 additions and 48 deletions.
Binary file modified hub/.doctrees/concepts/unify_api.doctree
Binary file not shown.
Binary file modified hub/.doctrees/docs/unify/unify/unify.utils.doctree
Binary file not shown.
Binary file modified hub/.doctrees/environment.pickle
Binary file not shown.
Binary file modified hub/.doctrees/home/home.doctree
Binary file not shown.
Binary file modified hub/.doctrees/index.doctree
Binary file not shown.
84 changes: 71 additions & 13 deletions hub/_sources/concepts/unify_api.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Our Universal API provides:
- A single, common interface for all models and providers 🟢
- One account, with one balance and one API key 🔑

To get your universal API key, simply `sign up<https://console.unify.ai>`_!
To get your universal API key, simply `sign up <https://console.unify.ai>`_!

Querying the API
----------------
Expand All @@ -37,9 +37,55 @@ Run the following command in a terminal (replacing :code:`$UNIFY_KEY` with your
"messages": [{"role": "user", "content": "Say hello."}]
}'
The :code:`model` field is used to specify both the model and the provider, in the format :code:`model@provider`. You can find a list of models and providers either in our `chat <https://unify.ai/chat>`_ interface, or through our `runtime benchmarks <https://unify.ai/benchmarks>`_.
The :code:`model` field is used to specify both the model and the provider, in the format :code:`model@provider`.

Requests can be made from any language, for example using Python:
You can find a list of all models, all providers and all endpoints (model + provider pairs) using the following commands:

.. code-block::
curl -X 'GET' \
'https://api.unify.ai/v0/models' \
-H 'Authorization: Bearer $UNIFY_KEY' \
-H 'accept: application/json'
.. code-block::
curl -X 'GET' \
'https://api.unify.ai/v0/providers' \
-H 'Authorization: Bearer $UNIFY_KEY' \
-H 'accept: application/json'
.. code-block::
curl -X 'GET' \
'https://api.unify.ai/v0/endpoints' \
-H 'Authorization: Bearer $UNIFY_KEY' \
-H 'accept: application/json'
You can also pass models and providers as arguments to the above functions, to limit the returned list, like so:

.. code-block::
curl -X 'GET' \
'https://api.unify.ai/v0/models?provider=<some_provider>' \
-H 'Authorization: Bearer $UNIFY_KEY' \
-H 'accept: application/json'
.. code-block::
curl -X 'GET' \
'https://api.unify.ai/v0/providers?model=<some_model>' \
-H 'Authorization: Bearer $UNIFY_KEY' \
-H 'accept: application/json'
.. code-block::
curl -X 'GET' \
'https://api.unify.ai/v0/endpoints?<model or provider>=<some_model or some_provider>' \
-H 'Authorization: Bearer $UNIFY_KEY' \
-H 'accept: application/json'
Requests can easily be made from any language, for example using Python:

.. code-block:: python
Expand Down Expand Up @@ -93,20 +139,24 @@ You can specify all of the parameters that OpenAI supports, but they may not be

Unify Python Package
^^^^^^^^^^^^^^^^^^^^
First, download our `Python package <https://github.com/unifyai/unify>`_ with :code:`pip install unifyai`.

There is complete documentation in the `readme <https://github.com/unifyai/unify/blob/main/README.md>`_.
Sample inference
First, download our `Python package <https://github.com/unifyai/unify>`_ with :code:`pip install unifyai`. You can then quickly get started like so:

.. code-block:: python
from unify import Unify
client = Unify("llama-3-8b-chat@fireworks-ai", api_key="$UNIFY_KEY")
response = client.generate("Say hi.")
import unify
client = unify.Unify("llama-3-8b-chat@fireworks-ai", api_key="$UNIFY_KEY")
response = client.generate("hello world!")
If you save your API key to the environment variables :code:`UNIFY_KEY`,
then you don't need to specify the :code:`api_key` argument in the example above.

You can list the models, providers and endpoints using the functions :code:`unify.utils.list_models()`,
:code:`unify.utils.list_providers()` and :code:`unify.utils.list_endpoints()`

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.
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.

.. code-block:: python
Expand All @@ -129,7 +179,7 @@ Remember that the :code:`model` field needs to contain a string of the form :cod

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

.. code-block:: javascript
Expand All @@ -152,7 +202,7 @@ You only have to manage the balance and billing details for your Unify account,

You can see your balance, top-up your balance, and set automatic refill on the `billing page <https://console.unify.ai/billing>`_.

You can get your current credit balance with a HTTP request:
You can also get your current credit balance with a HTTP request:

.. code-block::
Expand All @@ -170,8 +220,16 @@ which will return something like:
"credits": 232.32
}
This is also supported in our Python client:

.. code-block:: python
import unify
credits = unify.utils.get_credits()
Advanced features
-----------------

Custom endpoints
^^^^^^^^^^^^^^^^^
If you have a custom model which is deployed as an endpoint on (for example a fine-tuned model with OpenAI or Together AI) you can `add your own custom endpoint <https://console.unify.ai/endpoints>`_.
Expand Down
4 changes: 2 additions & 2 deletions hub/_sources/home/home.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Welcome to Unify!
We're on a mission to unify and simplify the LLM landscape. Unify lets you:

* **🔑 Use any LLM from any Provider**: With a single interface, you can use all LLMs from all providers by simply changing one string. No need to manage several API keys or handle different input-output formats. Unify handles all of that for you!
|

* **📊 Improve LLM Performance**: Add your own custom tests and evals, and benchmark your own prompts on all models and providers. Comparing quality, cost and speed, and iterate on your system prompt until all test cases pass, and you can deploy your app!
|

* **🔀 Route to the Best LLM**: Improve quality, cost and speed by routing to the perfect model and provider for each individual prompt.

Quick Start
Expand Down
70 changes: 58 additions & 12 deletions hub/concepts/unify_api.html
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ <h1>Universal API<a class="headerlink" href="#universal-api" title="Link to this
<li><p>A single, common interface for all models and providers 🟢</p></li>
<li><p>One account, with one balance and one API key 🔑</p></li>
</ul>
<p>To get your universal API key, simply <a href="#id1"><span class="problematic" id="id2">`sign up&lt;https://console.unify.ai&gt;`_</span></a>!</p>
<p>To get your universal API key, simply <a class="reference external" href="https://console.unify.ai">sign up</a>!</p>
<section id="querying-the-api">
<h2>Querying the API<a class="headerlink" href="#querying-the-api" title="Link to this heading">#</a></h2>
<p>You can interact with the API via:</p>
Expand All @@ -358,8 +358,46 @@ <h3>HTTP Requests<a class="headerlink" href="#http-requests" title="Link to this
<span class="p">}</span><span class="s1">&#39;</span>
</pre></div>
</div>
<p>The <code class="code docutils literal notranslate"><span class="pre">model</span></code> field is used to specify both the model and the provider, in the format <code class="code docutils literal notranslate"><span class="pre">model&#64;provider</span></code>. You can find a list of models and providers either in our <a class="reference external" href="https://unify.ai/chat">chat</a> interface, or through our <a class="reference external" href="https://unify.ai/benchmarks">runtime benchmarks</a>.</p>
<p>Requests can be made from any language, for example using Python:</p>
<p>The <code class="code docutils literal notranslate"><span class="pre">model</span></code> field is used to specify both the model and the provider, in the format <code class="code docutils literal notranslate"><span class="pre">model&#64;provider</span></code>.</p>
<p>You can find a list of all models, all providers and all endpoints (model + provider pairs) using the following commands:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">curl</span> <span class="o">-</span><span class="n">X</span> <span class="s1">&#39;GET&#39;</span> \
<span class="s1">&#39;https://api.unify.ai/v0/models&#39;</span> \
<span class="o">-</span><span class="n">H</span> <span class="s1">&#39;Authorization: Bearer $UNIFY_KEY&#39;</span> \
<span class="o">-</span><span class="n">H</span> <span class="s1">&#39;accept: application/json&#39;</span>
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">curl</span> <span class="o">-</span><span class="n">X</span> <span class="s1">&#39;GET&#39;</span> \
<span class="s1">&#39;https://api.unify.ai/v0/providers&#39;</span> \
<span class="o">-</span><span class="n">H</span> <span class="s1">&#39;Authorization: Bearer $UNIFY_KEY&#39;</span> \
<span class="o">-</span><span class="n">H</span> <span class="s1">&#39;accept: application/json&#39;</span>
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">curl</span> <span class="o">-</span><span class="n">X</span> <span class="s1">&#39;GET&#39;</span> \
<span class="s1">&#39;https://api.unify.ai/v0/endpoints&#39;</span> \
<span class="o">-</span><span class="n">H</span> <span class="s1">&#39;Authorization: Bearer $UNIFY_KEY&#39;</span> \
<span class="o">-</span><span class="n">H</span> <span class="s1">&#39;accept: application/json&#39;</span>
</pre></div>
</div>
<p>You can also pass models and providers as arguments to the above functions, to limit the returned list, like so:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">curl</span> <span class="o">-</span><span class="n">X</span> <span class="s1">&#39;GET&#39;</span> \
<span class="s1">&#39;https://api.unify.ai/v0/models?provider=&lt;some_provider&gt;&#39;</span> \
<span class="o">-</span><span class="n">H</span> <span class="s1">&#39;Authorization: Bearer $UNIFY_KEY&#39;</span> \
<span class="o">-</span><span class="n">H</span> <span class="s1">&#39;accept: application/json&#39;</span>
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">curl</span> <span class="o">-</span><span class="n">X</span> <span class="s1">&#39;GET&#39;</span> \
<span class="s1">&#39;https://api.unify.ai/v0/providers?model=&lt;some_model&gt;&#39;</span> \
<span class="o">-</span><span class="n">H</span> <span class="s1">&#39;Authorization: Bearer $UNIFY_KEY&#39;</span> \
<span class="o">-</span><span class="n">H</span> <span class="s1">&#39;accept: application/json&#39;</span>
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">curl</span> <span class="o">-</span><span class="n">X</span> <span class="s1">&#39;GET&#39;</span> \
<span class="s1">&#39;https://api.unify.ai/v0/endpoints?&lt;model or provider&gt;=&lt;some_model or some_provider&gt;&#39;</span> \
<span class="o">-</span><span class="n">H</span> <span class="s1">&#39;Authorization: Bearer $UNIFY_KEY&#39;</span> \
<span class="o">-</span><span class="n">H</span> <span class="s1">&#39;accept: application/json&#39;</span>
</pre></div>
</div>
<p>Requests can easily be made from any language, for example using Python:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">requests</span>

<span class="n">url</span> <span class="o">=</span> <span class="s2">&quot;https://api.unify.ai/v0/chat/completions&quot;</span>
Expand Down Expand Up @@ -408,18 +446,21 @@ <h3>HTTP Requests<a class="headerlink" href="#http-requests" title="Link to this
</section>
<section id="unify-python-package">
<h3>Unify Python Package<a class="headerlink" href="#unify-python-package" title="Link to this heading">#</a></h3>
<p>First, download our <a class="reference external" href="https://github.com/unifyai/unify">Python package</a> with <code class="code docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">unifyai</span></code>.</p>
<p>There is complete documentation in the <a class="reference external" href="https://github.com/unifyai/unify/blob/main/README.md">readme</a>.
Sample inference</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">unify</span> <span class="kn">import</span> <span class="n">Unify</span>
<span class="n">client</span> <span class="o">=</span> <span class="n">Unify</span><span class="p">(</span><span class="s2">&quot;llama-3-8b-chat@fireworks-ai&quot;</span><span class="p">,</span> <span class="n">api_key</span><span class="o">=</span><span class="s2">&quot;$UNIFY_KEY&quot;</span><span class="p">)</span>
<span class="n">response</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span><span class="s2">&quot;Say hi.&quot;</span><span class="p">)</span>
<p>First, download our <a class="reference external" href="https://github.com/unifyai/unify">Python package</a> with <code class="code docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">unifyai</span></code>. You can then quickly get started like so:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">unify</span>
<span class="n">client</span> <span class="o">=</span> <span class="n">unify</span><span class="o">.</span><span class="n">Unify</span><span class="p">(</span><span class="s2">&quot;llama-3-8b-chat@fireworks-ai&quot;</span><span class="p">,</span> <span class="n">api_key</span><span class="o">=</span><span class="s2">&quot;$UNIFY_KEY&quot;</span><span class="p">)</span>
<span class="n">response</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span><span class="s2">&quot;hello world!&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>If you save your API key to the environment variables <code class="code docutils literal notranslate"><span class="pre">UNIFY_KEY</span></code>,
then you don’t need to specify the <code class="code docutils literal notranslate"><span class="pre">api_key</span></code> argument in the example above.</p>
<p>You can list the models, providers and endpoints using the functions <code class="code docutils literal notranslate"><span class="pre">unify.utils.list_models()</span></code>,
<code class="code docutils literal notranslate"><span class="pre">unify.utils.list_providers()</span></code> and <code class="code docutils literal notranslate"><span class="pre">unify.utils.list_endpoints()</span></code></p>
</section>
<section id="openai-python-package">
<h3>OpenAI Python Package<a class="headerlink" href="#openai-python-package" title="Link to this heading">#</a></h3>
<p>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.</p>
<p>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.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">openai</span> <span class="kn">import</span> <span class="n">OpenAI</span>

<span class="n">client</span> <span class="o">=</span> <span class="n">OpenAI</span><span class="p">(</span>
Expand All @@ -440,7 +481,7 @@ <h3>OpenAI Python Package<a class="headerlink" href="#openai-python-package" tit
</section>
<section id="openai-nodejs-package">
<h3>OpenAI NodeJS Package<a class="headerlink" href="#openai-nodejs-package" title="Link to this heading">#</a></h3>
<p>Likewise, if you have existing code that uses the OpenAI NodeJS package, it’s straightforward to try out our API.</p>
<p>Likewise, if you have existing code that uses the OpenAI NodeJS package, it’s again very straightforward to try out our API.</p>
<div class="highlight-javascript notranslate"><div class="highlight"><pre><span></span><span class="kd">const</span><span class="w"> </span><span class="nx">openai</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="nx">OpenAI</span><span class="p">({</span>
<span class="w"> </span><span class="nx">baseUrl</span><span class="o">:</span><span class="w"> </span><span class="s2">&quot;https://api.unify.ai/v0/&quot;</span><span class="p">,</span>
<span class="w"> </span><span class="nx">apiKey</span><span class="o">:</span><span class="w"> </span><span class="s2">&quot;YOUR_UNIFY_KEY&quot;</span>
Expand All @@ -460,7 +501,7 @@ <h3>OpenAI NodeJS Package<a class="headerlink" href="#openai-nodejs-package" tit
<h2>Billing<a class="headerlink" href="#billing" title="Link to this heading">#</a></h2>
<p>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.</p>
<p>You can see your balance, top-up your balance, and set automatic refill on the <a class="reference external" href="https://console.unify.ai/billing">billing page</a>.</p>
<p>You can get your current credit balance with a HTTP request:</p>
<p>You can also get your current credit balance with a HTTP request:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">curl</span> <span class="o">-</span><span class="n">X</span> <span class="s1">&#39;GET&#39;</span> \
<span class="s1">&#39;https://api.unify.ai/v0/get_credits&#39;</span> \
<span class="o">-</span><span class="n">H</span> <span class="s1">&#39;accept: application/json&#39;</span> \
Expand All @@ -474,6 +515,11 @@ <h2>Billing<a class="headerlink" href="#billing" title="Link to this heading">#<
<span class="p">}</span>
</pre></div>
</div>
<p>This is also supported in our Python client:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">unify</span>
<span class="n">credits</span> <span class="o">=</span> <span class="n">unify</span><span class="o">.</span><span class="n">utils</span><span class="o">.</span><span class="n">get_credits</span><span class="p">()</span>
</pre></div>
</div>
</section>
<section id="advanced-features">
<h2>Advanced features<a class="headerlink" href="#advanced-features" title="Link to this heading">#</a></h2>
Expand Down
Loading

0 comments on commit f0684f6

Please sign in to comment.