Skip to content
Discussion options

You must be logged in to vote

Works for me.

Details

import net.http

fn main() {
    url := 'https://openrouter.ai/api/v1/chat/completions'

    model := 'deepseek/deepseek-r1-0528:free'
    question := 'What is the meaning of life?'

    // data := '{ "model": "${model}", "prompt": "${question}" } '
    // data := '{ "model": "${model}", "messages": { "prompt": "${question}" } }'
    data := '{ "model": "${model}", "messages": [ { "role": "user", "content": "${question}" } ], "temperature": 0.7 }'
    println(data)
    mut req := http.new_request(.post, url, data)
    req.user_agent = 'Mozilla/5.0 Firefox'
    req.add_header(.content_type, 'application/json')
    req.add_header(.authorization, 'Bearer sk-or-v1-xxxxx…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@luyuan1975
Comment options

Answer selected by luyuan1975
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants