IBM Support

Entering your API key and setting the CPLEX_STUDIO environment variables

Question & Answer


Question

Why do I need an API key and how do I set the CPLEX_STUDIO environment variables?

Cause

This Q&A concerns users of the CPLEX Optimization Studio monthly subscription via IBM Marketplace. This subscription is used in conjunction with the CPLEX Optimization Studio Community Edition but removes the limitations of that edition.

When you purchase a  Developer subscription on Marketplace using the self-service option, you receive an email that contains your API key.

You can also generate your own API key using IBM Cloud. See How to generate an API key for CPLEX Optimization Studio Download & Go subscription for details.

The API key unlocks the limitations on the size of models that the engines can solve. At the start of a solve, if a key was specified, the engine connects to an IBM server to check the validity of the key. It caches the result so as to not have to contact the server too frequently. Make sure you don't have any firewall or proxy settings preventing the product to connect to IBM servers for checking the key.

Answer

You can set your key using environment variables:

  • CPLEX_STUDIO_KEY_SERVER to identify the key server.
  • CPLEX_STUDIO_KEY to contain your API key.
 

NOTE Please use the following names for the CPLEX_STUDIO_DIR[version] environment variable, according to your version of CPLEX Optimization Studio:

  • V12.8: CPLEX_STUDIO_DIR128
  • V12.9: CPLEX_STUDIO_DIR129
  • V12.10: CPLEX_STUDIO_DIR1210
  • V20.1: CPLEX_STUDIO_DIR201
  • V22.1: CPLEX_STUDIO_DIR221
  • V22.1.1: CPLEX_STUDIO_DIR2211

To create the CPLEX_STUDIO environment variables:

This environment variables only need to be set for the current user and not system-wide.
Use the following procedure and then restart your machine.
 

For Windows:

  1. To create the CPLEX_STUDIO environment variables, open a command prompt and enter the following, using the API key you received by email:
     
    setx CPLEX_STUDIO_KEY "yourAPIkey"
    then enter
    setx CPLEX_STUDIO_KEY_SERVER "https://scx-cos.docloud.ibm.com/cos/query/v1/apikeys"
  2. Restart your machine after you have set the variables.

For Mac or Linux:

  1. First create the CPLEX_STUDIO_DIR[version] environment variable and set its value to your installation directory (by default this is /opt/ibm/ILOG/CPLEX_Studio_Community[version] on Linux, and /Applications/CPLEX_Studio_Community[version] on Mac).
  2. Then create the CPLEX_STUDIO environment variables. One way to do this is to run the following commands in a Terminal, using the API key you received by email:
    
      echo "export CPLEX_STUDIO_KEY=yourAPIkey" >> .bash_profile
      echo "export CPLEX_STUDIO_KEY_SERVER=https://scx-cos.docloud.ibm.com/cos/query/v1/apikeys" >> .bash_profile
    
  3. Restart your machine.

For more information see IBM ILOG CPLEX Optimization Studio V22.1.1 product documentation.
 

[{"Type":"MASTER","Line of Business":{"code":"LOB10","label":"Data and AI"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSSA5P","label":"IBM ILOG CPLEX Optimization Studio"},"ARM Category":[{"code":"a8m3p0000006wlWAAQ","label":"CPLEX Optimization Studio"}],"ARM Case Number":"","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"},{"code":"PF090","label":"macOS"}],"Version":"12.10.0;12.8.0;12.9.0;20.1.0;22.1.0;22.1.1"},{"Type":"MASTER","Line of Business":{"code":"LOB10","label":"Data and AI"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSSA5P","label":"IBM ILOG CPLEX Optimization Studio"},"ARM Category":[{"code":"a8m3p0000006wlWAAQ","label":"CPLEX Optimization Studio"}],"Platform":[{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"},{"code":"PF090","label":"macOS"}],"Version":"All Versions"}]

Document Information

Modified date:
22 June 2023

UID

swg22008948