---
title: "How to Generate & Store OpenAI Vector Embeddings with Turso"
description: "Turso's beta vector support stores OpenAI text-embedding-ada-002 embeddings in a libSQL F32_BLOB(1536) column, whose size matches the model's 1536 dimensions."
url: "https://swe.quest/articles/how-to-generate-store-openai-vector-embeddings-with-turso-1144f075a7bcad32"
canonical: "https://turso.tech/blog/how-to-generate-and-store-openai-vector-embeddings-with-turso"
source: "Turso"
published: "2024-07-01"
difficulty: "medium"
kind: "How-to"
reading_minutes: 5
tags: ["vector-search","sqlite","llms","javascript"]
---

# How to Generate & Store OpenAI Vector Embeddings with Turso

A post on [Turso](https://swe.quest/sources/turso.md), published 2024-07-01, 5 min read, How-to. Original: [https://turso.tech/blog/how-to-generate-and-store-openai-vector-embeddings-with-turso](https://turso.tech/blog/how-to-generate-and-store-openai-vector-embeddings-with-turso)

## Summary

Turso's beta vector support stores OpenAI text-embedding-ada-002 embeddings in a libSQL F32\_BLOB(1536) column, whose size matches the model's 1536 dimensions. A DiskANN index with a cosine metric, declared through libsql\_vector\_idx, handles similarity search. The walkthrough covers creating a vector-enabled group and database with the Turso CLI, generating embeddings with the OpenAI Node SDK, and inserting them as Float32Array buffers in batches of 50 via db.batch transactions. Larger documents such as PDFs need to be chunked before embedding to stay within API limits.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Vector search](https://swe.quest/tags/vector-search.md) (Data & databases)
- [SQLite](https://swe.quest/tags/sqlite.md) (Data & databases)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)

## Prerequisites

- vector embeddings basics ([easy posts on RAG & retrieval](https://swe.quest/tags/rag.md?difficulty=easy))
- SQL ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- Node.js ([easy posts on JavaScript](https://swe.quest/tags/javascript.md?difficulty=easy))

## Keywords

Turso, libSQL, OpenAI, text-embedding-ada-002, DiskANN, F32\_BLOB

## Related posts

- [Storing OpenAI embeddings in Postgres with pgvector](https://swe.quest/articles/storing-openai-embeddings-in-postgres-with-pgvector-19a5d03614f86fc6.md): Supabase · 2023-02-06 · Medium · 11 min read · Vector search, PostgreSQL, RAG & retrieval, LLMs
  pgvector adds a vector data type and distance operators (Euclidean \<-\>, negative inner product \<#\>, cosine \<=\>) to Postgres, so OpenAI text-embedding-ada-002 embeddings (1536 dimensions) can be stored and queried for similarity directly in the database.
- [Turso brings Native Vector Search to SQLite](https://swe.quest/articles/turso-brings-native-vector-search-to-sqlite-524b5f374ac6abee.md): Turso · 2024-06-05 · Medium · 5 min read · Vector search, SQLite, Multi-tenancy
  libSQL, the SQLite fork behind Turso, now has native vector similarity search exposed as a column type (F32\_BLOB) instead of an extension like sqlite-vss.
- [SQLite Retrieval Augmented Generation and Vector Search](https://swe.quest/articles/sqlite-retrieval-augmented-generation-and-vector-search-f6665825b9a1cb47.md): Turso · 2024-06-21 · Medium · 5 min read · Vector search, SQLite, RAG & retrieval
  Retrieval-augmented generation fixes stale or hallucinated LLM answers by retrieving relevant data, typically via embeddings and vector similarity search, and injecting it into the prompt. libSQL adds native vector search to SQLite: embeddings are stored in an F32\_BLOB column (SQLite treats column types as hints), inserted with a vector() function, and queried with vector\_distance\_cos() plus ORDER BY/LIMIT for exact top-k results.
- [Local RAG with Ollama, Mistral, and Turso](https://swe.quest/articles/local-rag-with-ollama-mistral-and-turso-c9414cc4e6a29ef6.md): Turso · 2025-01-08 · Medium · 8 min read · RAG & retrieval, Vector search, SQLite, Local-first & sync, TypeScript
  A local retrieval-augmented generation pipeline can be built in TypeScript using Ollama's Mistral model for both embeddings and generation, with libSQL storing documents and 4096-dimension F32\_BLOB vectors in a single SQLite file indexed via libsql\_vector\_idx.
- [Processing embeddings with libSQL, Redpanda Kafka, and Mixedbread](https://swe.quest/articles/processing-embeddings-with-libsql-redpanda-kafka-and-mixedbread-f174ef189355e5de.md): Turso · 2024-09-19 · Medium · 9 min read · Vector search, SQLite, Queues & messaging, Event-driven architecture, TypeScript
  Embedding generation can be moved out of the request path by publishing successful libSQL writes to a Kafka topic and computing vectors in a background consumer.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
