KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Testing 4D AIKit Without an OpenAI API Key
PRODUCT: 4D | VERSION: 20 R | PLATFORM: Mac & Win
Published On: January 13, 2026
Developers starting with 4D AIKit often face a missing OpenAI API key, particularly during early development, proof-of-concept work, or internal testing. Although an API key is required for production, it should not block experimentation or architectural validation.
To support this phase, 4D AIKit allows the use of OpenAI-compatible providers, including local or self-hosted AI servers.

For a list of supported OpenAI-compatible providers, see:
https://developer.4d.com/docs/aikit/compatible-openai

From 4D AIKit’s perspective, compatible providers behave the same way as OpenAI services. Core features such as chat completions, prompt handling remain available, with only the provider configuration changing.

Example:
In this example the local provider is Ollama, for set up please download it on the local machine and check their documentation for more information : https://docs.ollama.com/

var $client : cs.AIKit.OpenAI
var $config : Object

// Configure a compatible local provider
$config:=New object
$config.baseURL:="http://127.0.0.1:11434/v1"
$config.apiKey:="ollama" // Dummy key for compatible providers

// Create AI client
$client:=cs.AIKit.OpenAI.new($config)

// Simple test request
var $messages : Collection
$messages:=New collection
$messages.push(New object("role"; "user"; "content"; "Explain why do we need to use AI in Business?"))

// Execute request
var $result : Object
$result:=$client.chat.completions.create($messages; {model: "llama3"; max_tokens: 50; temperatue: 0.2})
If ($result.success)
  ALERT($result.choice.message.content)
End if


Note: Please make sure to download every model before adding it to the object parameters

These local providers are particularly useful for learning 4D AIKit, testing prompts, and designing application logic before moving to production.