Fetches URL content, extracts data, and transforms it using AI based on custom instructions. Use this to generate new content, summaries, or restructured data.
Parameters
JSON
import os
from tabstack import Tabstack
client = Tabstack(
api_key=os.environ.get("TABSTACK_API_KEY"), # This is the default and can be omitted
)
response = client.generate.json(
instructions="For each story, categorize it (tech/business/science/other) and write a one-sentence summary explaining what it's about in simple terms.",
json_schema={
"properties": {
"summaries": {
"items": {
"properties": {
"category": {
"description": "Story category (tech/business/science/etc)",
"type": "string",
},
"summary": {
"description": "One-sentence summary of the story",
"type": "string",
},
"title": {
"description": "Story title",
"type": "string",
},
},
"type": "object",
},
"type": "array",
}
},
"type": "object",
},
url="https://news.ycombinator.com",
)
print(response){
"foo": "bar"
}{
"error": "invalid JSON request body"
}{
"error": "json schema must be a valid object"
}{
"error": "instructions are required"
}{
"error": "json schema is required"
}{
"error": "url is required"
}{
"error": "failed to fetch URL"
}{
"error": "web page is too large"
}{
"error": "failed to transform data"
}Returns Examples
{
"foo": "bar"
}{
"error": "invalid JSON request body"
}{
"error": "json schema must be a valid object"
}{
"error": "instructions are required"
}{
"error": "json schema is required"
}{
"error": "url is required"
}{
"error": "failed to fetch URL"
}{
"error": "web page is too large"
}{
"error": "failed to transform data"
}