Files
herolib/lib/clients/openai
2025-10-13 08:30:42 +04:00
..
2025-01-12 16:33:48 +02:00
...
2025-08-06 08:50:32 +02:00
...
2025-08-08 15:46:01 +02:00
...
2025-08-06 08:50:32 +02:00
...
2025-08-06 08:50:32 +02:00
...
2025-10-13 08:30:42 +04:00

openai

To get started


import incubaid.herolib.clients.openai
import incubaid.herolib.core.playcmds

playcmds.run(
    heroscript:'
        !!openai.configure name:"default" 
            key:"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" 
            url:"https://openrouter.ai/api/v1" 
            model_default:"gpt-oss-120b"
        '
    reset: false
)!

//name:'default' is the default, you can change it to whatever you want
mut client:= openai.get()!

mut r:=client.chat_completion(
 model: "gpt-3.5-turbo",
 message: 'Hello, world!'
 temperature: 0.5
 max_completion_tokens: 1024
)!

if key empty then will try to get it from environment variable AIKEY or OPENROUTER_API_KEY