Magic Property | AllegroGraph 9.0.1
Author: Franz Incorporated

Copyright (c) 2005 - 2026 Franz, Incorporated
Last updated 27 May 2026 at 10:35

# SPARQL Magic Property

- Documentation Index
  - Release Notes
  - Quick Start
  - SSL/TLS Quick Start
  - Introduction
  - Setup and Configuration
    - Download
    - Server Installation
    - Server Configuration and Control
    - WebView
    - Database Upgrading
    - Managing Users
  - Server Management
    - Performance Tuning
    - Deleting Duplicate Triples
    - Purging Deleted Triples
    - Auditing
    - Managing Users
    - Replication
    - Point-in-Time Recovery
    - Transaction Log Archiving
    - Security Overview
    - Security Implementation
  - Tools
    - agtool
    - Data Loading
    - Data Export
    - Backup and Restore
    - Querying
    - RDFS++
    - Materializer
    - Event Scheduler
    - SHACL
  - Details
    - Triple Indices
    - Freetext Indices
    - Encoded IDs
    - Connection Pooling
    - N-dimensional Geospatial Overview
    - 2-D Geospatial
    - Temporal
    - Social Network
    - JavaScript
    - Datatypes
    - Data Conversion (Rapper)
    - Stored Procedures
    - Triple Attributes
    - Lineparse Format
  - Querying
    - SPARQL documentation summary
    - SPARQL Reference
    - SPIN
    - SPARQL Magic Properties
    - Prolog
  - 3rd-party tools
    - Solr text Indices
    - MongoDB integration
    - TopBraid Composer Plugin
    - Cloudera
  - Client APIs
    - Gruff
    - GraphTalker
    - REST/HTTP interface
    - HTTP reference
    - Javadocs (Sesame and Jena)
    - Python API
    - Lisp Reference
    - JavaScript
  - Tutorials
    - N-dimensional Geospatial
    - SPARQL Tutorial
    - Java Sesame
    - Java Jena
    - Python Sesame
    - Lisp
    - Prolog
    - More...
  - Other
    - Conferences and Seminars
    - Source Code on Github
    - Amazon EC2
    - Copyrights
  - Franz, Inc.

## http://franz.com/ns/allegrograph/8.0.0/llm/askForTable

Return a table of data with each row's values bound to the column variables in the subject argument.

Namespace:

    PREFIX llm: <http://franz.com/ns/allegrograph/8.0.0/llm/>

General forms:

    ?col0 llm:askForTable ?text
    (?col0 ?col1) llm:askForTable ?text
    (?col0 ?col1 ?col2) llm:askForTable ?text
    (?col0 ?col1 ?col2 ?col3) llm:askForTable ?text
    (?col0 ?col1 ?col2 ?col3 ... ?col31) llm:askForTable ?text

Example:

    PREFIX llm: <http://franz.com/ns/allegrograph/8.0.0/llm/>
    SELECT ?state ?capital ?pop ?area ?admitted ?governor ?celebrity {
      (?state ?capital ?pop ?area ?admitted ?governor ?celebrity) llm:askForTable "Make a table of US States, their capitals, population, area, year admitted to the Union, current governor and the most famous celebrity from that state."
    }

You can use the `llm:node` function to create a unique URI based on the values in the row

    bind(llm:node(?state) as ?stateNote).

Limitation:

Currently there is a limit of 32 columns in the subject arguments.

### API Key

If you are using OpenAI, you need an API key to utilize this predicate. (Ollama does not require a key but does require other setup as described in the Ollama document just linked.) See https://platform.openai.com/overview for instructions on obtaining a key (start with the Quickstart Tutorial and follow the links there to get a key).

If a vector repository is accessed the it likely that it contains an API key. However even if it does you may wish to use a different API key for this access to the LLM.

There are four ways to configure your API key, as a query option prefix or in a couple of places in the Allegrograph configuration.

Some magic predicates have an ?apiKey parameter in which case the API key can be given in the magic predicate expression and this overrides any other specification of an API key.

As a query option prefix, write:

    PREFIX franzOption_openaiApiKey: <franz:sk-U01ABc2defGHIJKlmnOpQ3RstvVWxyZABcD4eFG5jiJKlmno>

Syntax for config file:

    QueryOption openaiApiKey=<franz:sk-U01ABc2defGHIJKlmnOpQ3RstvVWxyZABcD4eFG5jiJKlmno>

In the file `data/settings/default-query-options`:

    (("franzOption_openaiApiKey" "<franz:sk-U01ABc2defGHIJKlmnOpQ3RstvVWxyZABcD4eFG5jiJKlmno>"))

### API Options

The proprietary OpenAI API exposes many options and parameters for interaction with their LLM models. Currently the AllegroGraph magic predicates and functions take an opinionated approach and hide most of these options behind the scenes. Specifically, we set

    API endpoint: https://api.openai.com/v1/chat/completions

Endpoint parameters:

    function-call: {"name":"table"}
    functions:
      {"name":"table", "description": "function to return tabular data.",
       "parameters":
       {"type":"object",
        "properties":
         {"rows":
          {"description": "the list of table rows",
           "type": "array",
           "items":
           {
            "type": "array",
            "items": {
              "type": "string",
              "description" : "the value in each column"}
    }}}}}]

Additionally we impose an API timeout of 10 seconds.

Finally, when the OpenAI API times out, returns an error, or the magic predicate implementation fails to parse the response, or any other error occurs, the magic predicate displays an informative message in Webview. Please contact AllegroGraph Support if you require different API options or customization.

### Notes

The following namespace abbreviations are used:

- fti - <http://franz.com/ns/allegrograph/2.2/textindex/>
- geo - <http://franz.com/ns/allegrograph/3.0/geospatial/>
- geofn - <http://franz.com/ns/allegrograph/3.0/geospatial/fn/>
- nd - <http://franz.com/ns/allegrograph/5.0/geo/nd#>
- ndfn - <http://franz.com/ns/allegrograph/5.0/geo/nd/fn#>
- sna - <http://franz.com/ns/allegrograph/4.11/sna/>

The SPARQL magic properties reference has additional information on using AllegroGraph magic properties and functions.