Embeddings
Embeddings convert text into vectors of floating‑point numbers. Distances between vectors correlate with semantic similarity.
Create embeddings
Section titled “Create embeddings”POST https://api.aifoundryhub.com/v1/embeddings
Creates one or more embeddings for the given input.
Example request
Section titled “Example request”curl -X POST "https://api.aifoundryhub.com/v1/embeddings" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $AI_FOUNDRY_HUB_API_KEY" \ -d '{ "model": "text-embedding-3-small", "input": ["Hello world"], "dimensions": 1536 }'import OpenAI from "openai";
const client = new OpenAI({ apiKey: process.env.AI_FOUNDRY_HUB_API_KEY, baseURL: "https://api.aifoundryhub.com/v1",});
const emb = await client.embeddings.create({ model: "text-embedding-3-small", input: ["Hello world"], dimensions: 1536,});
console.log(emb.data[0].embedding.length);package main
import ( "context" "fmt" "os"
openai "github.com/openai/openai-go" "github.com/openai/openai-go/option")
func main() { client := openai.NewClient( option.WithAPIKey(os.Getenv("AI_FOUNDRY_HUB_API_KEY")), option.WithBaseURL("https://api.aifoundryhub.com/v1"), )
params := openai.EmbeddingNewParams{ Model: "text-embedding-3-small", Input: openai.EmbeddingNewParamsInputUnion{ OfString: openai.String("The quick brown fox jumped over the lazy dog"), }, Dimensions: openai.Int(1536), }
ctx := context.Background() resp, err := client.Embeddings.New(ctx, params) if err != nil { panic(err) }
fmt.Println(len(resp.Data[0].Embedding))}import osfrom openai import OpenAI
client = OpenAI( api_key=os.getenv("AI_FOUNDRY_HUB_API_KEY"), base_url="https://api.aifoundryhub.com/v1",)
resp = client.embeddings.create( model="text-embedding-3-small", input=["Hello world"], dimensions=1536,)
print(len(resp.data[0].embedding))Returns
Section titled “Returns”An embedding response object containing one vector per input.
Example response
Section titled “Example response”{ "id": "embd_abc123", "object": "embedding_response", "created": 1714569952, "model": "text-embedding-3-small", "data": [ { "object": "embedding", "index": 0, "embedding": [0.0123, -0.0456, 0.0089] } ], "usage": { "prompt_tokens": 2, "total_tokens": 2 }}