Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

manage environment variables on the hosting platform

Hello JATOS community,

I’m currently working on a study hosted on a JATOS server and need to securely manage sensitive data such as API keys for an interaction study with Large Language Models. Ideally, I’d like to use environment variables for this purpose.

Does JATOS provide a way to set and manage environment variables on the hosting platform? If so, how can this be implemented? Are there specific configurations or best practices to follow to ensure these variables remain secure and accessible to the application?

We have set up already a JATOS Server on our University of Freiburg Server (https://weblab.psychologie.uni-freiburg.de/jatos).

Any advice, examples, or documentation references would be greatly appreciated!

Thanks in advance for your help!

Best,

Julius

Comments

  • Hi @Fenn_CAM ,

    Can you clarify how you would like to interact with the LLM? My guess is that you would like the experiment itself (so the code that runs in the browser of the participants) to interact with the LMM. Is that correct?

    — Sebastiaan

  • Hi,

    That is correct - the code is running on the client side (participants' browser) and they are sending API calls from their client (see code snippet below*). So presumably the API_KEY needs to be openly accessible, right?

    Best regards

    Julius


    *

    try {

        const response = await fetch('https://api.openai.com/v1/chat/completions', {

            method: 'POST',

            headers: {

                'Content-Type': 'application/json',

                'Authorization': `Bearer ${CONFIG.OPENAI_API_KEY}`

            },

            body: JSON.stringify({

                "model": "gpt-3.5-turbo",

                "messages": [

                    ...chatMemory,

                    {"role": "user", "content": userInput}

                ]

            })

        });


        if (!response.ok) {

            throw new Error('An error occurred in the request to the \'API');

        }

        ..

     }

  • It's always problematic security-wise to have API keys somewhere in the code on the client side because every code on the browser side can potentially be seen be the user. AFAIK the safe way to do this is to have yet another HTTP endpoint that has the only purpose to hand you the API key, this way you wouldn't have to have it in the code - but you'd need some kind of authentication for this endpoint, otherwise everyone could just request the API key. I don't think this approach is feasible for you.

    There is no way that JATOS hands over system's environment variables to the client side.

    But, I think, you can use JATOS' study, component or batch input to store the API key and hand it over to the client side. Those 'input' data are stored in JATOS database and handed over during initialization of a study run. You can then access them in your JS code with jatos.studyJsonInputjatos.componentJsonInput, or jatos.batchJsonInput. This way your API keys aren't hard-coded.

    I hope this helps,

    Kristian

  • Hey Kristian,

    thank you so much for your response! I also thought about setting up an API endoint (Next.js API hosted on https://vercel.com), but I would be unsecure how to secure the authentication for this endpoint (JSON Web Token,...)?

    My teams wants the study to be set up in few days and so I will stick to your second simpler approach.

    Thanks again!

    Best,

    Julius

  • Hi @Fenn_CAM ,

    If you are going to expose the token through the experiment code (even if it's not hard-coded as @kri suggests), then there is a very real possibility of it being intercepted and used by someone else. So absolutely do set a limit on the consumption for that token, and revoke it as soon as the study is done.

    In general, and again as @kri says, you would generally implement your own end-point on a custom server, and access the OpenAI through that route. But that would indeed take more than a few days to implement.

    — Sebastiaan

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games