Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# @decartai/tanstack-ai
# @decartai/tanstack-ai-adapter

Decart adapter for [TanStack AI](https://tanstack.com/ai) - image and video generation.

## Installation

```bash
npm install @decartai/tanstack-ai @tanstack/ai
npm install @decartai/tanstack-ai-adapter @tanstack/ai
```

## Setup
Expand All @@ -22,7 +22,7 @@ Or pass it directly when creating adapters.

```typescript
import { generateImage } from "@tanstack/ai";
import { decartImage } from "@decartai/tanstack-ai";
import { decartImage } from "@decartai/tanstack-ai-adapter";

const result = await generateImage({
adapter: decartImage("lucy-pro-t2i"),
Expand All @@ -35,7 +35,7 @@ console.log(result.images[0].b64Json); // Base64 image data
### With Explicit API Key

```typescript
import { createDecartImage } from "@decartai/tanstack-ai";
import { createDecartImage } from "@decartai/tanstack-ai-adapter";

const adapter = createDecartImage("lucy-pro-t2i", "your-api-key");
```
Expand All @@ -47,7 +47,7 @@ Video generation uses an async job/polling pattern.
```typescript
import { setTimeout } from "node:timers/promises";
import { generateVideo, getVideoJobStatus } from "@tanstack/ai";
import { decartVideo } from "@decartai/tanstack-ai";
import { decartVideo } from "@decartai/tanstack-ai-adapter";

const { jobId } = await generateVideo({
adapter: decartVideo("lucy-pro-t2v"),
Expand Down Expand Up @@ -95,7 +95,7 @@ console.log("Video ready:", videoUrl);
Full TypeScript support with model-specific type safety:

```typescript
import type { DecartImageModel, DecartVideoModel } from "@decartai/tanstack-ai";
import type { DecartImageModel, DecartVideoModel } from "@decartai/tanstack-ai-adapter";
```

## License
Expand Down
2 changes: 1 addition & 1 deletion examples/image-generation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { mkdirSync, writeFileSync } from "node:fs";
import path from "node:path";
import { decartImage } from "@decartai/tanstack-ai";
import { decartImage } from "@decartai/tanstack-ai-adapter";
import { generateImage } from "@tanstack/ai";

console.log("Generating image...");
Expand Down
2 changes: 1 addition & 1 deletion examples/video-generation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { mkdirSync, writeFileSync } from "node:fs";
import path from "node:path";
import { setTimeout } from "node:timers/promises";
import { decartVideo } from "@decartai/tanstack-ai";
import { decartVideo } from "@decartai/tanstack-ai-adapter";
import { generateVideo, getVideoJobStatus } from "@tanstack/ai";

const { jobId } = await generateVideo({
Expand Down
2 changes: 1 addition & 1 deletion examples/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"preview": "vite preview"
},
"dependencies": {
"@decartai/tanstack-ai": "workspace:*",
"@decartai/tanstack-ai-adapter": "workspace:*",
"@tanstack/ai": "^0.2.0",
"@tanstack/react-ai-devtools": "^0.1.1",
"@tanstack/react-devtools": "^0.9.0",
Expand Down
51 changes: 42 additions & 9 deletions examples/web/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { useState } from "react";
import { createDecartImage } from "@decartai/tanstack-ai-adapter";
import { generateImage } from "@tanstack/ai";
import { createDecartImage } from "@decartai/tanstack-ai";
import { TanStackDevtools } from "@tanstack/react-devtools";
import { aiDevtoolsPlugin } from "@tanstack/react-ai-devtools";
import { TanStackDevtools } from "@tanstack/react-devtools";
import { useState } from "react";

function App() {
const [apiKey, setApiKey] = useState(localStorage.getItem("DECART_API_KEY") || "");
const [apiKey, setApiKey] = useState(
localStorage.getItem("DECART_API_KEY") || ""
);
const [prompt, setPrompt] = useState("A beautiful sunset over the ocean");
const [imageUrl, setImageUrl] = useState<string | null>(null);
const [loading, setLoading] = useState(false);
Expand Down Expand Up @@ -44,11 +46,24 @@ function App() {
};

return (
<div style={{ fontFamily: "system-ui", padding: "2rem", maxWidth: "800px", margin: "0 auto" }}>
<div
style={{
fontFamily: "system-ui",
padding: "2rem",
maxWidth: "800px",
margin: "0 auto",
}}
>
<h1>Decart TanStack AI Demo</h1>

<div style={{ marginBottom: "1rem" }}>
<label style={{ display: "block", marginBottom: "0.5rem", fontWeight: "bold" }}>
<label
style={{
display: "block",
marginBottom: "0.5rem",
fontWeight: "bold",
}}
>
Decart API Key
</label>
<input
Expand All @@ -61,7 +76,13 @@ function App() {
</div>

<div style={{ marginBottom: "1rem" }}>
<label style={{ display: "block", marginBottom: "0.5rem", fontWeight: "bold" }}>
<label
style={{
display: "block",
marginBottom: "0.5rem",
fontWeight: "bold",
}}
>
Prompt
</label>
<textarea
Expand Down Expand Up @@ -89,15 +110,27 @@ function App() {
</button>

{error && (
<div style={{ marginTop: "1rem", padding: "1rem", backgroundColor: "#fee", color: "#c00", borderRadius: "4px" }}>
<div
style={{
marginTop: "1rem",
padding: "1rem",
backgroundColor: "#fee",
color: "#c00",
borderRadius: "4px",
}}
>
{error}
</div>
)}

{imageUrl && (
<div style={{ marginTop: "2rem" }}>
<h2>Generated Image</h2>
<img src={imageUrl} alt="Generated" style={{ maxWidth: "100%", borderRadius: "8px" }} />
<img
src={imageUrl}
alt="Generated"
style={{ maxWidth: "100%", borderRadius: "8px" }}
/>
</div>
)}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@decartai/tanstack-ai",
"name": "@decartai/tanstack-ai-adapter",
"version": "0.0.1",
"type": "module",
"description": "Decart adapter for TanStack AI - image and video generation",
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading