1. Set up your account
Head to the Isaacus Platform to create a new account. Once signed up, add a payment method to claim your free credits. After adding a payment method, create a new API key. Make sure to keep your API key safe. You won’t be able to see it again after you create it. But don’t worry, you can always generate a new one.2. Install the Isaacus API client
Now that your account is set up, install our Python or server-side JavaScript/TypeScript API client (or check out our API reference if you’re not using either of those languages).3. Embed a document
With our API client installed, let’s embed our first legal query and document. To start, you need to initialize the client with your API key. You can do this by setting theISAACUS_API_KEY
environment variable or by passing it directly, which is what we’re doing in this example.
.embeddings.create()
method of our API client. We’ll also make sure to flag that we’re embedding a document by setting the task
parameter to "retrieval/document"
. This will help our embedder produce an embedding that is optimized specifically for being retrieved. We recommend always setting the task
parameter to either "retrieval/document"
or "retrieval/query"
when using our embedders for retrieval tasks, even if the text in question is not strictly a document or a query, so long as one text is being treated as something to be retrieved, and the other as something to retrieve it with.
document_response.embeddings[0]
, in addition to our usage statistics.
document_response.embeddings
is an array of embedding results, sorted in the same order as the input texts. Each embedding result contains embedding
, which is the actual embedding, and index
, which is the index of the input text that the embedding corresponds to (starting from ).
document_response.usage
contains statistics about the usage of resources in the process of generating the embedding. document_response.usage.input_tokens
will give you the number of tokens inputted into the embedder, which you can cross-reference with our pricing to estimate the cost of embedding the document (excluding applicable taxes).
Now, let’s embed two search queries, one that is clearly relevant to the document and another that is clearly irrelevant. This time we set our task
parameter to "retrieval/query"
to indicate that we’re embedding a search query.
numpy
’s dot
function to compute the dot product of our embeddings (which is equivalent to their cosine similarity since all our embeddings are L2-normalized). If you prefer, you can use another library to compute the cosine similarity of the embeddings (e.g., torch
via torch.nn.functional.cosine_similarity
), or you could write your own implementation (as we do for our JavaScript example).
4. Next steps
Beyond the examples we’ve shared here, there’s a lot more that you can do with the Isaacus API. To learn how to take full advantage of the API, you can check out our:- Capabilities section, which covers the full range of tasks the Isaacus API supports, including embedding, reranking, extractive question answering and universal classification.
- API reference, which documents how to interface with our API and the endpoints and parameters that are available.
- Pricing section, which shows just how affordable our API is.