-- Local Jev-compatible servers (stuntd, laya-server): no API key is needed unless jev.api_url is *.typesafe.ai. -- The mock accepts requests without an Authorization header under /local/. \set VERBOSITY terse SET jev.notices = off; SET jev.api_key = ''; CREATE TABLE local_cities (id int, name text, country text); INSERT INTO local_cities VALUES (1, 'Berlin', 'Germany'), (2, 'Tokyo', 'Japan'), (3, 'Munich', 'Germany'); -- A local server without auth: requests are sent without an Authorization header SET jev.api_url = 'http://127.0.0.1:8765/local/v1/systemone'; SELECT name FROM local_cities WHERE jev(local_cities, 'the country is Germany') ORDER BY id; name -------- Berlin Munich (2 rows) SELECT name, jev_choice(local_cities, 'which team', ARRAY['red', 'blue']) AS team FROM local_cities ORDER BY id; name | team --------+------ Berlin | blue Tokyo | red Munich | blue (3 rows) -- A key, when set, is still sent to a local server SET jev.api_key = 'wrong-key'; SELECT jev(local_cities, 'the country is Japan') FROM local_cities; ERROR: plpy.Error: jev: TypeSafe API error 401 {"error": "invalid api key"} SET jev.api_key = 'test-key'; SELECT name FROM local_cities WHERE jev(local_cities, 'the city is Tokyo') ORDER BY id; name ------- Tokyo (1 row) -- An endpoint that does require a key reports its own error instead of the missing-key error SET jev.api_key = ''; SET jev.api_url = 'http://127.0.0.1:8765/v1/systemone'; SELECT jev(local_cities, 'the city is Lima') FROM local_cities; ERROR: plpy.Error: jev: TypeSafe API error 401 {"error": "invalid api key"} -- Any *.typesafe.ai host still needs a key, checked before any request is made SET jev.api_url = 'https://EU.api.typesafe.ai/v1/systemone'; SELECT jev(local_cities, 'the city is Lima') FROM local_cities; ERROR: plpy.Error: jev: no API key. SET jev.api_key = '...' or start the server with TYPESAFE_API_KEY set. SET jev.api_url = 'https://typesafe.ai/v1/systemone'; SELECT jev(local_cities, 'the city is Lima') FROM local_cities; ERROR: plpy.Error: jev: no API key. SET jev.api_key = '...' or start the server with TYPESAFE_API_KEY set.